From 4da81e6c005510f7d25ed743a95437ae279642b8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 10 Dec 2021 08:31:01 +0000 Subject: [PATCH] CodeGen from PR 17039 in Azure/azure-rest-api-specs [Go] Add other resources module name (#17039) * [Go] Add other resources module name * fix --- sdk/resources/azure-mgmt-resource/_meta.json | 10 +- .../deploymentscripts/_configuration.py | 4 +- .../_deployment_scripts_client.py | 5 +- .../deploymentscripts/aio/_configuration.py | 4 +- .../aio/_deployment_scripts_client.py | 6 +- .../v2019_10_01_preview/__init__.py | 9 +- .../v2019_10_01_preview/_configuration.py | 6 +- .../_deployment_scripts_client.py | 67 +- .../v2019_10_01_preview/_metadata.json | 21 +- .../v2019_10_01_preview/_patch.py | 31 + .../v2019_10_01_preview/_vendor.py | 27 + .../v2019_10_01_preview/_version.py | 2 +- .../v2019_10_01_preview/aio/__init__.py | 5 + .../v2019_10_01_preview/aio/_configuration.py | 6 +- .../aio/_deployment_scripts_client.py | 69 +- .../v2019_10_01_preview/aio/_patch.py | 31 + .../_deployment_scripts_operations.py | 369 +- .../_deployment_scripts_client_enums.py | 29 +- .../v2019_10_01_preview/models/_models.py | 684 ++- .../v2019_10_01_preview/models/_models_py3.py | 684 ++- .../_deployment_scripts_operations.py | 666 ++- .../deploymentscripts/v2020_10_01/__init__.py | 9 +- .../v2020_10_01/_configuration.py | 6 +- .../v2020_10_01/_deployment_scripts_client.py | 67 +- .../v2020_10_01/_metadata.json | 21 +- .../deploymentscripts/v2020_10_01/_patch.py | 31 + .../deploymentscripts/v2020_10_01/_vendor.py | 27 + .../deploymentscripts/v2020_10_01/_version.py | 2 +- .../v2020_10_01/aio/__init__.py | 5 + .../v2020_10_01/aio/_configuration.py | 6 +- .../aio/_deployment_scripts_client.py | 69 +- .../v2020_10_01/aio/_patch.py | 31 + .../_deployment_scripts_operations.py | 369 +- .../_deployment_scripts_client_enums.py | 29 +- .../v2020_10_01/models/_models.py | 678 ++- .../v2020_10_01/models/_models_py3.py | 678 ++- .../_deployment_scripts_operations.py | 666 ++- .../mgmt/resource/features/_configuration.py | 4 +- .../mgmt/resource/features/_feature_client.py | 5 +- .../resource/features/_operations_mixin.py | 15 +- .../resource/features/aio/_configuration.py | 4 +- .../resource/features/aio/_feature_client.py | 6 +- .../features/aio/_operations_mixin.py | 14 +- .../resource/features/v2015_12_01/__init__.py | 9 +- .../features/v2015_12_01/_configuration.py | 6 +- .../features/v2015_12_01/_feature_client.py | 62 +- .../features/v2015_12_01/_metadata.json | 33 +- .../resource/features/v2015_12_01/_patch.py | 31 + .../resource/features/v2015_12_01/_vendor.py | 27 + .../resource/features/v2015_12_01/_version.py | 2 +- .../features/v2015_12_01/aio/__init__.py | 5 + .../v2015_12_01/aio/_configuration.py | 6 +- .../v2015_12_01/aio/_feature_client.py | 62 +- .../features/v2015_12_01/aio/_patch.py | 31 + .../operations/_feature_client_operations.py | 45 +- .../aio/operations/_features_operations.py | 199 +- .../features/v2015_12_01/models/_models.py | 96 +- .../v2015_12_01/models/_models_py3.py | 96 +- .../operations/_feature_client_operations.py | 74 +- .../operations/_features_operations.py | 376 +- .../resource/features/v2021_07_01/__init__.py | 9 +- .../features/v2021_07_01/_configuration.py | 6 +- .../features/v2021_07_01/_feature_client.py | 69 +- .../features/v2021_07_01/_metadata.json | 33 +- .../resource/features/v2021_07_01/_patch.py | 31 + .../resource/features/v2021_07_01/_vendor.py | 27 + .../resource/features/v2021_07_01/_version.py | 2 +- .../features/v2021_07_01/aio/__init__.py | 5 + .../v2021_07_01/aio/_configuration.py | 6 +- .../v2021_07_01/aio/_feature_client.py | 69 +- .../features/v2021_07_01/aio/_patch.py | 31 + .../operations/_feature_client_operations.py | 47 +- .../aio/operations/_features_operations.py | 209 +- ...iption_feature_registrations_operations.py | 223 +- .../models/_feature_client_enums.py | 23 +- .../features/v2021_07_01/models/_models.py | 178 +- .../v2021_07_01/models/_models_py3.py | 178 +- .../operations/_feature_client_operations.py | 76 +- .../operations/_features_operations.py | 386 +- ...iption_feature_registrations_operations.py | 404 +- .../mgmt/resource/links/_configuration.py | 4 +- .../resource/links/_management_link_client.py | 5 +- .../mgmt/resource/links/aio/_configuration.py | 4 +- .../links/aio/_management_link_client.py | 6 +- .../resource/links/v2016_09_01/__init__.py | 9 +- .../links/v2016_09_01/_configuration.py | 6 +- .../v2016_09_01/_management_link_client.py | 68 +- .../resource/links/v2016_09_01/_metadata.json | 21 +- .../mgmt/resource/links/v2016_09_01/_patch.py | 31 + .../resource/links/v2016_09_01/_vendor.py | 27 + .../resource/links/v2016_09_01/_version.py | 2 +- .../links/v2016_09_01/aio/__init__.py | 5 + .../links/v2016_09_01/aio/_configuration.py | 6 +- .../aio/_management_link_client.py | 70 +- .../resource/links/v2016_09_01/aio/_patch.py | 31 + .../v2016_09_01/aio/operations/_operations.py | 45 +- .../operations/_resource_links_operations.py | 193 +- .../links/v2016_09_01/models/_models.py | 92 +- .../links/v2016_09_01/models/_models_py3.py | 92 +- .../v2016_09_01/operations/_operations.py | 74 +- .../operations/_resource_links_operations.py | 362 +- .../mgmt/resource/locks/_configuration.py | 4 +- .../resource/locks/_management_lock_client.py | 5 +- .../mgmt/resource/locks/aio/_configuration.py | 4 +- .../locks/aio/_management_lock_client.py | 6 +- .../resource/locks/v2015_01_01/__init__.py | 9 +- .../locks/v2015_01_01/_configuration.py | 6 +- .../v2015_01_01/_management_lock_client.py | 64 +- .../resource/locks/v2015_01_01/_metadata.json | 21 +- .../mgmt/resource/locks/v2015_01_01/_patch.py | 31 + .../resource/locks/v2015_01_01/_vendor.py | 27 + .../resource/locks/v2015_01_01/_version.py | 2 +- .../locks/v2015_01_01/aio/__init__.py | 5 + .../locks/v2015_01_01/aio/_configuration.py | 6 +- .../aio/_management_lock_client.py | 66 +- .../resource/locks/v2015_01_01/aio/_patch.py | 31 + .../_management_locks_operations.py | 455 +- .../models/_management_lock_client_enums.py | 21 +- .../locks/v2015_01_01/models/_models.py | 35 +- .../locks/v2015_01_01/models/_models_py3.py | 35 +- .../_management_locks_operations.py | 870 ++-- .../resource/locks/v2016_09_01/__init__.py | 9 +- .../locks/v2016_09_01/_configuration.py | 6 +- .../v2016_09_01/_management_lock_client.py | 71 +- .../resource/locks/v2016_09_01/_metadata.json | 21 +- .../mgmt/resource/locks/v2016_09_01/_patch.py | 31 + .../resource/locks/v2016_09_01/_vendor.py | 27 + .../resource/locks/v2016_09_01/_version.py | 2 +- .../locks/v2016_09_01/aio/__init__.py | 5 + .../locks/v2016_09_01/aio/_configuration.py | 6 +- .../aio/_management_lock_client.py | 73 +- .../resource/locks/v2016_09_01/aio/_patch.py | 31 + .../_authorization_operations_operations.py | 45 +- .../_management_locks_operations.py | 637 ++- .../models/_management_lock_client_enums.py | 21 +- .../locks/v2016_09_01/models/_models.py | 94 +- .../locks/v2016_09_01/models/_models_py3.py | 94 +- .../_authorization_operations_operations.py | 74 +- .../_management_locks_operations.py | 1232 ++++-- .../resource/managedapplications/__init__.py | 9 +- .../_application_client.py | 75 +- .../managedapplications/_configuration.py | 6 +- .../managedapplications/_metadata.json | 33 +- .../resource/managedapplications/_patch.py | 31 + .../resource/managedapplications/_vendor.py | 27 + .../resource/managedapplications/_version.py | 2 +- .../managedapplications/aio/__init__.py | 5 + .../aio/_application_client.py | 75 +- .../managedapplications/aio/_configuration.py | 6 +- .../managedapplications/aio/_patch.py | 31 + .../_application_client_operations.py | 45 +- .../_application_definitions_operations.py | 385 +- .../operations/_applications_operations.py | 504 +-- .../models/_application_client_enums.py | 25 +- .../managedapplications/models/_models.py | 523 ++- .../managedapplications/models/_models_py3.py | 523 ++- .../_application_client_operations.py | 74 +- .../_application_definitions_operations.py | 646 ++- .../operations/_applications_operations.py | 861 ++-- .../mgmt/resource/policy/_configuration.py | 4 +- .../mgmt/resource/policy/_policy_client.py | 5 +- .../resource/policy/aio/_configuration.py | 4 +- .../resource/policy/aio/_policy_client.py | 6 +- .../policy/v2015_10_01_preview/__init__.py | 9 +- .../v2015_10_01_preview/_configuration.py | 6 +- .../policy/v2015_10_01_preview/_metadata.json | 21 +- .../policy/v2015_10_01_preview/_patch.py | 31 + .../v2015_10_01_preview/_policy_client.py | 71 +- .../policy/v2015_10_01_preview/_vendor.py | 27 + .../policy/v2015_10_01_preview/_version.py | 2 +- .../v2015_10_01_preview/aio/__init__.py | 5 + .../v2015_10_01_preview/aio/_configuration.py | 6 +- .../policy/v2015_10_01_preview/aio/_patch.py | 31 + .../v2015_10_01_preview/aio/_policy_client.py | 73 +- .../_policy_assignments_operations.py | 364 +- .../_policy_definitions_operations.py | 152 +- .../v2015_10_01_preview/models/_models.py | 101 +- .../v2015_10_01_preview/models/_models_py3.py | 101 +- .../models/_policy_client_enums.py | 21 +- .../_policy_assignments_operations.py | 693 ++- .../_policy_definitions_operations.py | 291 +- .../resource/policy/v2016_04_01/__init__.py | 9 +- .../policy/v2016_04_01/_configuration.py | 6 +- .../policy/v2016_04_01/_metadata.json | 21 +- .../resource/policy/v2016_04_01/_patch.py | 31 + .../policy/v2016_04_01/_policy_client.py | 71 +- .../resource/policy/v2016_04_01/_vendor.py | 27 + .../resource/policy/v2016_04_01/_version.py | 2 +- .../policy/v2016_04_01/aio/__init__.py | 5 + .../policy/v2016_04_01/aio/_configuration.py | 6 +- .../resource/policy/v2016_04_01/aio/_patch.py | 31 + .../policy/v2016_04_01/aio/_policy_client.py | 73 +- .../_policy_assignments_operations.py | 364 +- .../_policy_definitions_operations.py | 152 +- .../policy/v2016_04_01/models/_models.py | 100 +- .../policy/v2016_04_01/models/_models_py3.py | 100 +- .../models/_policy_client_enums.py | 21 +- .../_policy_assignments_operations.py | 693 ++- .../_policy_definitions_operations.py | 291 +- .../resource/policy/v2016_12_01/__init__.py | 9 +- .../policy/v2016_12_01/_configuration.py | 6 +- .../policy/v2016_12_01/_metadata.json | 21 +- .../resource/policy/v2016_12_01/_patch.py | 31 + .../policy/v2016_12_01/_policy_client.py | 71 +- .../resource/policy/v2016_12_01/_vendor.py | 27 + .../resource/policy/v2016_12_01/_version.py | 2 +- .../policy/v2016_12_01/aio/__init__.py | 5 + .../policy/v2016_12_01/aio/_configuration.py | 6 +- .../resource/policy/v2016_12_01/aio/_patch.py | 31 + .../policy/v2016_12_01/aio/_policy_client.py | 73 +- .../_policy_assignments_operations.py | 364 +- .../_policy_definitions_operations.py | 353 +- .../policy/v2016_12_01/models/_models.py | 118 +- .../policy/v2016_12_01/models/_models_py3.py | 118 +- .../models/_policy_client_enums.py | 23 +- .../_policy_assignments_operations.py | 693 ++- .../_policy_definitions_operations.py | 678 ++- .../policy/v2017_06_01_preview/__init__.py | 9 +- .../v2017_06_01_preview/_configuration.py | 6 +- .../policy/v2017_06_01_preview/_metadata.json | 21 +- .../policy/v2017_06_01_preview/_patch.py | 31 + .../v2017_06_01_preview/_policy_client.py | 78 +- .../policy/v2017_06_01_preview/_vendor.py | 27 + .../policy/v2017_06_01_preview/_version.py | 2 +- .../v2017_06_01_preview/aio/__init__.py | 5 + .../v2017_06_01_preview/aio/_configuration.py | 6 +- .../policy/v2017_06_01_preview/aio/_patch.py | 31 + .../v2017_06_01_preview/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 382 +- .../_policy_definitions_operations.py | 353 +- .../_policy_set_definitions_operations.py | 377 +- .../v2017_06_01_preview/models/_models.py | 231 +- .../v2017_06_01_preview/models/_models_py3.py | 231 +- .../models/_policy_client_enums.py | 23 +- .../_policy_assignments_operations.py | 711 +++- .../_policy_definitions_operations.py | 678 ++- .../_policy_set_definitions_operations.py | 714 +++- .../resource/policy/v2018_03_01/__init__.py | 9 +- .../policy/v2018_03_01/_configuration.py | 6 +- .../policy/v2018_03_01/_metadata.json | 21 +- .../resource/policy/v2018_03_01/_patch.py | 31 + .../policy/v2018_03_01/_policy_client.py | 78 +- .../resource/policy/v2018_03_01/_vendor.py | 27 + .../resource/policy/v2018_03_01/_version.py | 2 +- .../policy/v2018_03_01/aio/__init__.py | 5 + .../policy/v2018_03_01/aio/_configuration.py | 6 +- .../resource/policy/v2018_03_01/aio/_patch.py | 31 + .../policy/v2018_03_01/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 382 +- .../_policy_definitions_operations.py | 353 +- .../_policy_set_definitions_operations.py | 377 +- .../policy/v2018_03_01/models/_models.py | 228 +- .../policy/v2018_03_01/models/_models_py3.py | 228 +- .../models/_policy_client_enums.py | 23 +- .../_policy_assignments_operations.py | 711 +++- .../_policy_definitions_operations.py | 678 ++- .../_policy_set_definitions_operations.py | 714 +++- .../resource/policy/v2018_05_01/__init__.py | 9 +- .../policy/v2018_05_01/_configuration.py | 6 +- .../policy/v2018_05_01/_metadata.json | 21 +- .../resource/policy/v2018_05_01/_patch.py | 31 + .../policy/v2018_05_01/_policy_client.py | 78 +- .../resource/policy/v2018_05_01/_vendor.py | 27 + .../resource/policy/v2018_05_01/_version.py | 2 +- .../policy/v2018_05_01/aio/__init__.py | 5 + .../policy/v2018_05_01/aio/_configuration.py | 6 +- .../resource/policy/v2018_05_01/aio/_patch.py | 31 + .../policy/v2018_05_01/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 382 +- .../_policy_definitions_operations.py | 353 +- .../_policy_set_definitions_operations.py | 377 +- .../policy/v2018_05_01/models/_models.py | 249 +- .../policy/v2018_05_01/models/_models_py3.py | 249 +- .../models/_policy_client_enums.py | 25 +- .../_policy_assignments_operations.py | 711 +++- .../_policy_definitions_operations.py | 678 ++- .../_policy_set_definitions_operations.py | 714 +++- .../resource/policy/v2019_01_01/__init__.py | 9 +- .../policy/v2019_01_01/_configuration.py | 6 +- .../policy/v2019_01_01/_metadata.json | 21 +- .../resource/policy/v2019_01_01/_patch.py | 31 + .../policy/v2019_01_01/_policy_client.py | 78 +- .../resource/policy/v2019_01_01/_vendor.py | 27 + .../resource/policy/v2019_01_01/_version.py | 2 +- .../policy/v2019_01_01/aio/__init__.py | 5 + .../policy/v2019_01_01/aio/_configuration.py | 6 +- .../resource/policy/v2019_01_01/aio/_patch.py | 31 + .../policy/v2019_01_01/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 382 +- .../_policy_definitions_operations.py | 353 +- .../_policy_set_definitions_operations.py | 377 +- .../policy/v2019_01_01/models/_models.py | 249 +- .../policy/v2019_01_01/models/_models_py3.py | 249 +- .../models/_policy_client_enums.py | 23 +- .../_policy_assignments_operations.py | 711 +++- .../_policy_definitions_operations.py | 678 ++- .../_policy_set_definitions_operations.py | 714 +++- .../resource/policy/v2019_06_01/__init__.py | 9 +- .../policy/v2019_06_01/_configuration.py | 6 +- .../policy/v2019_06_01/_metadata.json | 21 +- .../resource/policy/v2019_06_01/_patch.py | 31 + .../policy/v2019_06_01/_policy_client.py | 78 +- .../resource/policy/v2019_06_01/_vendor.py | 27 + .../resource/policy/v2019_06_01/_version.py | 2 +- .../policy/v2019_06_01/aio/__init__.py | 5 + .../policy/v2019_06_01/aio/_configuration.py | 6 +- .../resource/policy/v2019_06_01/aio/_patch.py | 31 + .../policy/v2019_06_01/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 382 +- .../_policy_definitions_operations.py | 353 +- .../_policy_set_definitions_operations.py | 377 +- .../policy/v2019_06_01/models/_models.py | 260 +- .../policy/v2019_06_01/models/_models_py3.py | 260 +- .../models/_policy_client_enums.py | 25 +- .../_policy_assignments_operations.py | 711 +++- .../_policy_definitions_operations.py | 678 ++- .../_policy_set_definitions_operations.py | 714 +++- .../resource/policy/v2019_09_01/__init__.py | 9 +- .../policy/v2019_09_01/_configuration.py | 6 +- .../policy/v2019_09_01/_metadata.json | 21 +- .../resource/policy/v2019_09_01/_patch.py | 31 + .../policy/v2019_09_01/_policy_client.py | 78 +- .../resource/policy/v2019_09_01/_vendor.py | 27 + .../resource/policy/v2019_09_01/_version.py | 2 +- .../policy/v2019_09_01/aio/__init__.py | 5 + .../policy/v2019_09_01/aio/_configuration.py | 6 +- .../resource/policy/v2019_09_01/aio/_patch.py | 31 + .../policy/v2019_09_01/aio/_policy_client.py | 80 +- .../_policy_assignments_operations.py | 414 +- .../_policy_definitions_operations.py | 357 +- .../_policy_set_definitions_operations.py | 357 +- .../policy/v2019_09_01/models/_models.py | 370 +- .../policy/v2019_09_01/models/_models_py3.py | 370 +- .../models/_policy_client_enums.py | 27 +- .../_policy_assignments_operations.py | 778 +++- .../_policy_definitions_operations.py | 694 ++- .../_policy_set_definitions_operations.py | 694 ++- .../resource/policy/v2020_09_01/__init__.py | 9 +- .../policy/v2020_09_01/_configuration.py | 6 +- .../policy/v2020_09_01/_metadata.json | 21 +- .../resource/policy/v2020_09_01/_patch.py | 31 + .../policy/v2020_09_01/_policy_client.py | 94 +- .../resource/policy/v2020_09_01/_vendor.py | 27 + .../resource/policy/v2020_09_01/_version.py | 2 +- .../policy/v2020_09_01/aio/__init__.py | 5 + .../policy/v2020_09_01/aio/_configuration.py | 6 +- .../resource/policy/v2020_09_01/aio/_patch.py | 31 + .../policy/v2020_09_01/aio/_policy_client.py | 96 +- .../_data_policy_manifests_operations.py | 81 +- .../_policy_assignments_operations.py | 431 +- .../_policy_definitions_operations.py | 383 +- .../_policy_exemptions_operations.py | 325 +- .../_policy_set_definitions_operations.py | 383 +- .../policy/v2020_09_01/models/_models.py | 689 ++- .../policy/v2020_09_01/models/_models_py3.py | 689 ++- .../models/_policy_client_enums.py | 39 +- .../_data_policy_manifests_operations.py | 146 +- .../_policy_assignments_operations.py | 808 ++-- .../_policy_definitions_operations.py | 741 +++- .../_policy_exemptions_operations.py | 590 ++- .../_policy_set_definitions_operations.py | 741 +++- .../resource/policy/v2021_06_01/__init__.py | 9 +- .../policy/v2021_06_01/_configuration.py | 6 +- .../policy/v2021_06_01/_metadata.json | 21 +- .../resource/policy/v2021_06_01/_patch.py | 31 + .../policy/v2021_06_01/_policy_client.py | 94 +- .../resource/policy/v2021_06_01/_vendor.py | 27 + .../resource/policy/v2021_06_01/_version.py | 2 +- .../policy/v2021_06_01/aio/__init__.py | 5 + .../policy/v2021_06_01/aio/_configuration.py | 6 +- .../resource/policy/v2021_06_01/aio/_patch.py | 31 + .../policy/v2021_06_01/aio/_policy_client.py | 96 +- .../_data_policy_manifests_operations.py | 81 +- .../_policy_assignments_operations.py | 503 +-- .../_policy_definitions_operations.py | 383 +- .../_policy_exemptions_operations.py | 325 +- .../_policy_set_definitions_operations.py | 383 +- .../policy/v2021_06_01/models/_models.py | 718 +++- .../policy/v2021_06_01/models/_models_py3.py | 718 +++- .../models/_policy_client_enums.py | 39 +- .../_data_policy_manifests_operations.py | 146 +- .../_policy_assignments_operations.py | 954 +++-- .../_policy_definitions_operations.py | 741 +++- .../_policy_exemptions_operations.py | 590 ++- .../_policy_set_definitions_operations.py | 741 +++- .../mgmt/resource/resources/_configuration.py | 4 +- .../resources/_resource_management_client.py | 5 +- .../resource/resources/aio/_configuration.py | 4 +- .../aio/_resource_management_client.py | 6 +- .../resources/v2016_02_01/__init__.py | 9 +- .../resources/v2016_02_01/_configuration.py | 6 +- .../resources/v2016_02_01/_metadata.json | 21 +- .../resource/resources/v2016_02_01/_patch.py | 31 + .../_resource_management_client.py | 95 +- .../resource/resources/v2016_02_01/_vendor.py | 27 + .../resources/v2016_02_01/_version.py | 2 +- .../resources/v2016_02_01/aio/__init__.py | 5 + .../v2016_02_01/aio/_configuration.py | 6 +- .../resources/v2016_02_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 103 +- .../_deployment_operations_operations.py | 99 +- .../aio/operations/_deployments_operations.py | 383 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 338 +- .../aio/operations/_resources_operations.py | 360 +- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2016_02_01/models/_models.py | 958 +++-- .../v2016_02_01/models/_models_py3.py | 958 +++-- .../_resource_management_client_enums.py | 21 +- .../_deployment_operations_operations.py | 180 +- .../operations/_deployments_operations.py | 699 +++- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 628 ++- .../operations/_resources_operations.py | 650 ++- .../operations/_tags_operations.py | 330 +- .../resources/v2016_09_01/__init__.py | 9 +- .../resources/v2016_09_01/_configuration.py | 6 +- .../resources/v2016_09_01/_metadata.json | 21 +- .../resource/resources/v2016_09_01/_patch.py | 31 + .../_resource_management_client.py | 95 +- .../resource/resources/v2016_09_01/_vendor.py | 27 + .../resources/v2016_09_01/_version.py | 2 +- .../resources/v2016_09_01/aio/__init__.py | 5 + .../v2016_09_01/aio/_configuration.py | 6 +- .../resources/v2016_09_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 103 +- .../_deployment_operations_operations.py | 99 +- .../aio/operations/_deployments_operations.py | 383 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 338 +- .../aio/operations/_resources_operations.py | 643 ++- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2016_09_01/models/_models.py | 843 ++-- .../v2016_09_01/models/_models_py3.py | 843 ++-- .../_resource_management_client_enums.py | 21 +- .../_deployment_operations_operations.py | 180 +- .../operations/_deployments_operations.py | 699 +++- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 628 ++- .../operations/_resources_operations.py | 1092 +++-- .../operations/_tags_operations.py | 330 +- .../resources/v2017_05_10/__init__.py | 9 +- .../resources/v2017_05_10/_configuration.py | 6 +- .../resources/v2017_05_10/_metadata.json | 21 +- .../resource/resources/v2017_05_10/_patch.py | 31 + .../_resource_management_client.py | 95 +- .../resource/resources/v2017_05_10/_vendor.py | 27 + .../resources/v2017_05_10/_version.py | 2 +- .../resources/v2017_05_10/aio/__init__.py | 5 + .../v2017_05_10/aio/_configuration.py | 6 +- .../resources/v2017_05_10/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 103 +- .../_deployment_operations_operations.py | 99 +- .../aio/operations/_deployments_operations.py | 383 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2017_05_10/models/_models.py | 876 ++-- .../v2017_05_10/models/_models_py3.py | 876 ++-- .../_resource_management_client_enums.py | 21 +- .../_deployment_operations_operations.py | 180 +- .../operations/_deployments_operations.py | 699 +++- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2018_02_01/__init__.py | 9 +- .../resources/v2018_02_01/_configuration.py | 6 +- .../resources/v2018_02_01/_metadata.json | 21 +- .../resource/resources/v2018_02_01/_patch.py | 31 + .../_resource_management_client.py | 95 +- .../resource/resources/v2018_02_01/_vendor.py | 27 + .../resources/v2018_02_01/_version.py | 2 +- .../resources/v2018_02_01/aio/__init__.py | 5 + .../v2018_02_01/aio/_configuration.py | 6 +- .../resources/v2018_02_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 103 +- .../_deployment_operations_operations.py | 99 +- .../aio/operations/_deployments_operations.py | 383 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2018_02_01/models/_models.py | 921 ++-- .../v2018_02_01/models/_models_py3.py | 921 ++-- .../_resource_management_client_enums.py | 25 +- .../_deployment_operations_operations.py | 180 +- .../operations/_deployments_operations.py | 699 +++- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2018_05_01/__init__.py | 9 +- .../resources/v2018_05_01/_configuration.py | 6 +- .../resources/v2018_05_01/_metadata.json | 21 +- .../resource/resources/v2018_05_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2018_05_01/_vendor.py | 27 + .../resources/v2018_05_01/_version.py | 2 +- .../resources/v2018_05_01/aio/__init__.py | 5 + .../v2018_05_01/aio/_configuration.py | 6 +- .../resources/v2018_05_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 184 +- .../aio/operations/_deployments_operations.py | 702 ++-- .../v2018_05_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2018_05_01/models/_models.py | 986 +++-- .../v2018_05_01/models/_models_py3.py | 986 +++-- .../_resource_management_client_enums.py | 25 +- .../_deployment_operations_operations.py | 339 +- .../operations/_deployments_operations.py | 1285 ++++-- .../v2018_05_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2019_03_01/__init__.py | 9 +- .../resources/v2019_03_01/_configuration.py | 6 +- .../resources/v2019_03_01/_metadata.json | 21 +- .../resource/resources/v2019_03_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_03_01/_vendor.py | 27 + .../resources/v2019_03_01/_version.py | 2 +- .../resources/v2019_03_01/aio/__init__.py | 5 + .../v2019_03_01/aio/_configuration.py | 6 +- .../resources/v2019_03_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 184 +- .../aio/operations/_deployments_operations.py | 702 ++-- .../v2019_03_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2019_03_01/models/_models.py | 992 +++-- .../v2019_03_01/models/_models_py3.py | 992 +++-- .../_resource_management_client_enums.py | 25 +- .../_deployment_operations_operations.py | 339 +- .../operations/_deployments_operations.py | 1285 ++++-- .../v2019_03_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2019_05_01/__init__.py | 9 +- .../resources/v2019_05_01/_configuration.py | 6 +- .../resources/v2019_05_01/_metadata.json | 21 +- .../resource/resources/v2019_05_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_05_01/_vendor.py | 27 + .../resources/v2019_05_01/_version.py | 2 +- .../resources/v2019_05_01/aio/__init__.py | 5 + .../v2019_05_01/aio/_configuration.py | 6 +- .../resources/v2019_05_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 269 +- .../aio/operations/_deployments_operations.py | 1021 ++--- .../v2019_05_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 151 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2019_05_01/models/_models.py | 992 +++-- .../v2019_05_01/models/_models_py3.py | 992 +++-- .../_resource_management_client_enums.py | 25 +- .../_deployment_operations_operations.py | 498 ++- .../operations/_deployments_operations.py | 1871 ++++++--- .../v2019_05_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 299 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2019_05_10/__init__.py | 9 +- .../resources/v2019_05_10/_configuration.py | 6 +- .../resources/v2019_05_10/_metadata.json | 21 +- .../resource/resources/v2019_05_10/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_05_10/_vendor.py | 27 + .../resources/v2019_05_10/_version.py | 2 +- .../resources/v2019_05_10/aio/__init__.py | 5 + .../v2019_05_10/aio/_configuration.py | 6 +- .../resources/v2019_05_10/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 269 +- .../aio/operations/_deployments_operations.py | 1021 ++--- .../v2019_05_10/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 227 +- .../operations/_resource_groups_operations.py | 279 +- .../aio/operations/_resources_operations.py | 761 ++-- .../aio/operations/_tags_operations.py | 167 +- .../resources/v2019_05_10/models/_models.py | 992 +++-- .../v2019_05_10/models/_models_py3.py | 992 +++-- .../_resource_management_client_enums.py | 25 +- .../_deployment_operations_operations.py | 498 ++- .../operations/_deployments_operations.py | 1871 ++++++--- .../v2019_05_10/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 444 +- .../operations/_resource_groups_operations.py | 525 ++- .../operations/_resources_operations.py | 1290 ++++-- .../operations/_tags_operations.py | 330 +- .../resources/v2019_07_01/__init__.py | 9 +- .../resources/v2019_07_01/_configuration.py | 6 +- .../resources/v2019_07_01/_metadata.json | 21 +- .../resource/resources/v2019_07_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_07_01/_vendor.py | 27 + .../resources/v2019_07_01/_version.py | 2 +- .../resources/v2019_07_01/aio/__init__.py | 5 + .../v2019_07_01/aio/_configuration.py | 6 +- .../resources/v2019_07_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 1812 ++++---- .../v2019_07_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 227 +- .../operations/_resource_groups_operations.py | 283 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 171 +- .../resources/v2019_07_01/models/_models.py | 1170 ++++-- .../v2019_07_01/models/_models_py3.py | 1170 ++++-- .../_resource_management_client_enums.py | 31 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3344 ++++++++++----- .../v2019_07_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 444 +- .../operations/_resource_groups_operations.py | 541 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 346 +- .../resources/v2019_08_01/__init__.py | 9 +- .../resources/v2019_08_01/_configuration.py | 6 +- .../resources/v2019_08_01/_metadata.json | 21 +- .../resource/resources/v2019_08_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_08_01/_vendor.py | 27 + .../resources/v2019_08_01/_version.py | 2 +- .../resources/v2019_08_01/aio/__init__.py | 5 + .../v2019_08_01/aio/_configuration.py | 6 +- .../resources/v2019_08_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 1812 ++++---- .../v2019_08_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 227 +- .../operations/_resource_groups_operations.py | 314 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 171 +- .../resources/v2019_08_01/models/_models.py | 1184 ++++-- .../v2019_08_01/models/_models_py3.py | 1184 ++++-- .../_resource_management_client_enums.py | 31 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3344 ++++++++++----- .../v2019_08_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 444 +- .../operations/_resource_groups_operations.py | 572 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 346 +- .../resources/v2019_10_01/__init__.py | 9 +- .../resources/v2019_10_01/_configuration.py | 6 +- .../resources/v2019_10_01/_metadata.json | 21 +- .../resource/resources/v2019_10_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2019_10_01/_vendor.py | 27 + .../resources/v2019_10_01/_version.py | 2 +- .../resources/v2019_10_01/aio/__init__.py | 5 + .../v2019_10_01/aio/_configuration.py | 6 +- .../resources/v2019_10_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 2106 ++++------ .../v2019_10_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 227 +- .../operations/_resource_groups_operations.py | 314 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 294 +- .../resources/v2019_10_01/models/_models.py | 1227 ++++-- .../v2019_10_01/models/_models_py3.py | 1227 ++++-- .../_resource_management_client_enums.py | 39 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3712 +++++++++++------ .../v2019_10_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 444 +- .../operations/_resource_groups_operations.py | 572 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 605 ++- .../resources/v2020_06_01/__init__.py | 9 +- .../resources/v2020_06_01/_configuration.py | 6 +- .../resources/v2020_06_01/_metadata.json | 21 +- .../resource/resources/v2020_06_01/_patch.py | 31 + .../_resource_management_client.py | 99 +- .../resource/resources/v2020_06_01/_vendor.py | 27 + .../resources/v2020_06_01/_version.py | 2 +- .../resources/v2020_06_01/aio/__init__.py | 5 + .../v2020_06_01/aio/_configuration.py | 6 +- .../resources/v2020_06_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 107 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 2106 ++++------ .../v2020_06_01/aio/operations/_operations.py | 45 +- .../aio/operations/_providers_operations.py | 255 +- .../operations/_resource_groups_operations.py | 317 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 294 +- .../resources/v2020_06_01/models/_models.py | 1288 ++++-- .../v2020_06_01/models/_models_py3.py | 1288 ++++-- .../_resource_management_client_enums.py | 47 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3712 +++++++++++------ .../v2020_06_01/operations/_operations.py | 74 +- .../operations/_providers_operations.py | 506 ++- .../operations/_resource_groups_operations.py | 579 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 605 ++- .../resources/v2020_10_01/__init__.py | 9 +- .../resources/v2020_10_01/_configuration.py | 6 +- .../resources/v2020_10_01/_metadata.json | 21 +- .../resource/resources/v2020_10_01/_patch.py | 31 + .../_resource_management_client.py | 106 +- .../resource/resources/v2020_10_01/_vendor.py | 27 + .../resources/v2020_10_01/_version.py | 2 +- .../resources/v2020_10_01/aio/__init__.py | 5 + .../v2020_10_01/aio/_configuration.py | 6 +- .../resources/v2020_10_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 114 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 2106 ++++------ .../v2020_10_01/aio/operations/_operations.py | 45 +- .../_provider_resource_types_operations.py | 40 +- .../aio/operations/_providers_operations.py | 255 +- .../operations/_resource_groups_operations.py | 314 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 294 +- .../resources/v2020_10_01/models/_models.py | 1332 ++++-- .../v2020_10_01/models/_models_py3.py | 1332 ++++-- .../_resource_management_client_enums.py | 47 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3712 +++++++++++------ .../v2020_10_01/operations/_operations.py | 74 +- .../_provider_resource_types_operations.py | 82 +- .../operations/_providers_operations.py | 506 ++- .../operations/_resource_groups_operations.py | 572 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 605 ++- .../resources/v2021_01_01/__init__.py | 9 +- .../resources/v2021_01_01/_configuration.py | 6 +- .../resources/v2021_01_01/_metadata.json | 21 +- .../resource/resources/v2021_01_01/_patch.py | 31 + .../_resource_management_client.py | 106 +- .../resource/resources/v2021_01_01/_vendor.py | 27 + .../resources/v2021_01_01/_version.py | 2 +- .../resources/v2021_01_01/aio/__init__.py | 5 + .../v2021_01_01/aio/_configuration.py | 6 +- .../resources/v2021_01_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 114 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 2106 ++++------ .../v2021_01_01/aio/operations/_operations.py | 45 +- .../_provider_resource_types_operations.py | 40 +- .../aio/operations/_providers_operations.py | 255 +- .../operations/_resource_groups_operations.py | 317 +- .../aio/operations/_resources_operations.py | 773 ++-- .../aio/operations/_tags_operations.py | 294 +- .../resources/v2021_01_01/models/__init__.py | 3 + .../resources/v2021_01_01/models/_models.py | 1388 ++++-- .../v2021_01_01/models/_models_py3.py | 1392 +++++-- .../_resource_management_client_enums.py | 49 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3712 +++++++++++------ .../v2021_01_01/operations/_operations.py | 74 +- .../_provider_resource_types_operations.py | 82 +- .../operations/_providers_operations.py | 506 ++- .../operations/_resource_groups_operations.py | 579 ++- .../operations/_resources_operations.py | 1330 ++++-- .../operations/_tags_operations.py | 605 ++- .../resources/v2021_04_01/__init__.py | 9 +- .../resources/v2021_04_01/_configuration.py | 6 +- .../resources/v2021_04_01/_metadata.json | 21 +- .../resource/resources/v2021_04_01/_patch.py | 31 + .../_resource_management_client.py | 106 +- .../resource/resources/v2021_04_01/_vendor.py | 27 + .../resources/v2021_04_01/_version.py | 2 +- .../resources/v2021_04_01/aio/__init__.py | 5 + .../v2021_04_01/aio/_configuration.py | 6 +- .../resources/v2021_04_01/aio/_patch.py | 31 + .../aio/_resource_management_client.py | 114 +- .../_deployment_operations_operations.py | 434 +- .../aio/operations/_deployments_operations.py | 2106 ++++------ .../v2021_04_01/aio/operations/_operations.py | 45 +- .../_provider_resource_types_operations.py | 40 +- .../aio/operations/_providers_operations.py | 288 +- .../operations/_resource_groups_operations.py | 317 +- .../aio/operations/_resources_operations.py | 792 ++-- .../aio/operations/_tags_operations.py | 294 +- .../resources/v2021_04_01/models/__init__.py | 3 + .../resources/v2021_04_01/models/_models.py | 1509 +++++-- .../v2021_04_01/models/_models_py3.py | 1513 +++++-- .../_resource_management_client_enums.py | 51 +- .../_deployment_operations_operations.py | 807 ++-- .../operations/_deployments_operations.py | 3712 +++++++++++------ .../v2021_04_01/operations/_operations.py | 74 +- .../_provider_resource_types_operations.py | 82 +- .../operations/_providers_operations.py | 571 ++- .../operations/_resource_groups_operations.py | 579 ++- .../operations/_resources_operations.py | 1349 ++++-- .../operations/_tags_operations.py | 605 ++- .../resource/subscriptions/_configuration.py | 4 +- .../subscriptions/_operations_mixin.py | 12 +- .../subscriptions/_subscription_client.py | 5 +- .../subscriptions/aio/_configuration.py | 4 +- .../subscriptions/aio/_operations_mixin.py | 11 +- .../subscriptions/aio/_subscription_client.py | 6 +- .../subscriptions/v2016_06_01/__init__.py | 9 +- .../v2016_06_01/_configuration.py | 6 +- .../subscriptions/v2016_06_01/_metadata.json | 31 +- .../subscriptions/v2016_06_01/_patch.py | 31 + .../v2016_06_01/_subscription_client.py | 70 +- .../subscriptions/v2016_06_01/_vendor.py | 27 + .../subscriptions/v2016_06_01/_version.py | 2 +- .../subscriptions/v2016_06_01/aio/__init__.py | 5 + .../v2016_06_01/aio/_configuration.py | 6 +- .../subscriptions/v2016_06_01/aio/_patch.py | 31 + .../v2016_06_01/aio/_subscription_client.py | 73 +- .../v2016_06_01/aio/operations/_operations.py | 45 +- .../_subscription_client_operations.py | 47 +- .../operations/_subscriptions_operations.py | 119 +- .../aio/operations/_tenants_operations.py | 45 +- .../v2016_06_01/models/_models.py | 173 +- .../v2016_06_01/models/_models_py3.py | 173 +- .../models/_subscription_client_enums.py | 25 +- .../v2016_06_01/operations/_operations.py | 74 +- .../_subscription_client_operations.py | 81 +- .../operations/_subscriptions_operations.py | 212 +- .../operations/_tenants_operations.py | 74 +- .../subscriptions/v2018_06_01/__init__.py | 9 +- .../v2018_06_01/_configuration.py | 6 +- .../subscriptions/v2018_06_01/_metadata.json | 31 +- .../subscriptions/v2018_06_01/_patch.py | 31 + .../v2018_06_01/_subscription_client.py | 70 +- .../subscriptions/v2018_06_01/_vendor.py | 27 + .../subscriptions/v2018_06_01/_version.py | 2 +- .../subscriptions/v2018_06_01/aio/__init__.py | 5 + .../v2018_06_01/aio/_configuration.py | 6 +- .../subscriptions/v2018_06_01/aio/_patch.py | 31 + .../v2018_06_01/aio/_subscription_client.py | 73 +- .../v2018_06_01/aio/operations/_operations.py | 45 +- .../_subscription_client_operations.py | 47 +- .../operations/_subscriptions_operations.py | 119 +- .../aio/operations/_tenants_operations.py | 45 +- .../v2018_06_01/models/_models.py | 173 +- .../v2018_06_01/models/_models_py3.py | 173 +- .../models/_subscription_client_enums.py | 25 +- .../v2018_06_01/operations/_operations.py | 74 +- .../_subscription_client_operations.py | 81 +- .../operations/_subscriptions_operations.py | 212 +- .../operations/_tenants_operations.py | 74 +- .../subscriptions/v2019_06_01/__init__.py | 9 +- .../v2019_06_01/_configuration.py | 6 +- .../subscriptions/v2019_06_01/_metadata.json | 31 +- .../subscriptions/v2019_06_01/_patch.py | 31 + .../v2019_06_01/_subscription_client.py | 70 +- .../subscriptions/v2019_06_01/_vendor.py | 27 + .../subscriptions/v2019_06_01/_version.py | 2 +- .../subscriptions/v2019_06_01/aio/__init__.py | 5 + .../v2019_06_01/aio/_configuration.py | 6 +- .../subscriptions/v2019_06_01/aio/_patch.py | 31 + .../v2019_06_01/aio/_subscription_client.py | 73 +- .../v2019_06_01/aio/operations/_operations.py | 45 +- .../_subscription_client_operations.py | 47 +- .../operations/_subscriptions_operations.py | 119 +- .../aio/operations/_tenants_operations.py | 45 +- .../v2019_06_01/models/_models.py | 182 +- .../v2019_06_01/models/_models_py3.py | 182 +- .../models/_subscription_client_enums.py | 27 +- .../v2019_06_01/operations/_operations.py | 74 +- .../_subscription_client_operations.py | 81 +- .../operations/_subscriptions_operations.py | 212 +- .../operations/_tenants_operations.py | 74 +- .../subscriptions/v2019_11_01/__init__.py | 9 +- .../v2019_11_01/_configuration.py | 6 +- .../subscriptions/v2019_11_01/_metadata.json | 31 +- .../subscriptions/v2019_11_01/_patch.py | 31 + .../v2019_11_01/_subscription_client.py | 70 +- .../subscriptions/v2019_11_01/_vendor.py | 27 + .../subscriptions/v2019_11_01/_version.py | 2 +- .../subscriptions/v2019_11_01/aio/__init__.py | 5 + .../v2019_11_01/aio/_configuration.py | 6 +- .../subscriptions/v2019_11_01/aio/_patch.py | 31 + .../v2019_11_01/aio/_subscription_client.py | 73 +- .../v2019_11_01/aio/operations/_operations.py | 45 +- .../_subscription_client_operations.py | 47 +- .../operations/_subscriptions_operations.py | 119 +- .../aio/operations/_tenants_operations.py | 45 +- .../v2019_11_01/models/_models.py | 206 +- .../v2019_11_01/models/_models_py3.py | 206 +- .../models/_subscription_client_enums.py | 31 +- .../v2019_11_01/operations/_operations.py | 74 +- .../_subscription_client_operations.py | 81 +- .../operations/_subscriptions_operations.py | 212 +- .../operations/_tenants_operations.py | 74 +- .../subscriptions/v2021_01_01/__init__.py | 9 +- .../v2021_01_01/_configuration.py | 6 +- .../subscriptions/v2021_01_01/_metadata.json | 31 +- .../subscriptions/v2021_01_01/_patch.py | 31 + .../v2021_01_01/_subscription_client.py | 66 +- .../subscriptions/v2021_01_01/_vendor.py | 27 + .../subscriptions/v2021_01_01/_version.py | 2 +- .../subscriptions/v2021_01_01/aio/__init__.py | 5 + .../v2021_01_01/aio/_configuration.py | 6 +- .../subscriptions/v2021_01_01/aio/_patch.py | 31 + .../v2021_01_01/aio/_subscription_client.py | 69 +- .../_subscription_client_operations.py | 45 +- .../operations/_subscriptions_operations.py | 123 +- .../aio/operations/_tenants_operations.py | 45 +- .../v2021_01_01/models/_models.py | 188 +- .../v2021_01_01/models/_models_py3.py | 188 +- .../models/_subscription_client_enums.py | 33 +- .../_subscription_client_operations.py | 79 +- .../operations/_subscriptions_operations.py | 220 +- .../operations/_tenants_operations.py | 74 +- .../resource/templatespecs/_configuration.py | 4 +- .../templatespecs/_template_specs_client.py | 5 +- .../templatespecs/aio/_configuration.py | 4 +- .../aio/_template_specs_client.py | 6 +- .../v2019_06_01_preview/__init__.py | 9 +- .../v2019_06_01_preview/_configuration.py | 6 +- .../v2019_06_01_preview/_metadata.json | 21 +- .../v2019_06_01_preview/_patch.py | 31 + .../_template_specs_client.py | 71 +- .../v2019_06_01_preview/_vendor.py | 27 + .../v2019_06_01_preview/_version.py | 2 +- .../v2019_06_01_preview/aio/__init__.py | 5 + .../v2019_06_01_preview/aio/_configuration.py | 6 +- .../v2019_06_01_preview/aio/_patch.py | 31 + .../aio/_template_specs_client.py | 73 +- .../_template_spec_versions_operations.py | 229 +- .../operations/_template_specs_operations.py | 284 +- .../v2019_06_01_preview/models/_models.py | 193 +- .../v2019_06_01_preview/models/_models_py3.py | 193 +- .../models/_template_specs_client_enums.py | 25 +- .../_template_spec_versions_operations.py | 428 +- .../operations/_template_specs_operations.py | 517 ++- .../v2021_03_01_preview/__init__.py | 9 +- .../v2021_03_01_preview/_configuration.py | 6 +- .../v2021_03_01_preview/_metadata.json | 21 +- .../v2021_03_01_preview/_patch.py | 31 + .../_template_specs_client.py | 71 +- .../v2021_03_01_preview/_vendor.py | 27 + .../v2021_03_01_preview/_version.py | 2 +- .../v2021_03_01_preview/aio/__init__.py | 5 + .../v2021_03_01_preview/aio/_configuration.py | 6 +- .../v2021_03_01_preview/aio/_patch.py | 31 + .../aio/_template_specs_client.py | 73 +- .../_template_spec_versions_operations.py | 229 +- .../operations/_template_specs_operations.py | 284 +- .../v2021_03_01_preview/models/_models.py | 195 +- .../v2021_03_01_preview/models/_models_py3.py | 195 +- .../models/_template_specs_client_enums.py | 23 +- .../_template_spec_versions_operations.py | 428 +- .../operations/_template_specs_operations.py | 517 ++- .../templatespecs/v2021_05_01/__init__.py | 9 +- .../v2021_05_01/_configuration.py | 6 +- .../templatespecs/v2021_05_01/_metadata.json | 21 +- .../templatespecs/v2021_05_01/_patch.py | 31 + .../v2021_05_01/_template_specs_client.py | 71 +- .../templatespecs/v2021_05_01/_vendor.py | 27 + .../templatespecs/v2021_05_01/_version.py | 2 +- .../templatespecs/v2021_05_01/aio/__init__.py | 5 + .../v2021_05_01/aio/_configuration.py | 6 +- .../templatespecs/v2021_05_01/aio/_patch.py | 31 + .../v2021_05_01/aio/_template_specs_client.py | 73 +- .../_template_spec_versions_operations.py | 229 +- .../operations/_template_specs_operations.py | 284 +- .../v2021_05_01/models/_models.py | 193 +- .../v2021_05_01/models/_models_py3.py | 193 +- .../models/_template_specs_client_enums.py | 23 +- .../_template_spec_versions_operations.py | 428 +- .../operations/_template_specs_operations.py | 517 ++- 981 files changed, 153185 insertions(+), 89915 deletions(-) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py diff --git a/sdk/resources/azure-mgmt-resource/_meta.json b/sdk/resources/azure-mgmt-resource/_meta.json index eea88351f49fa..b5bee9cff25a9 100644 --- a/sdk/resources/azure-mgmt-resource/_meta.json +++ b/sdk/resources/azure-mgmt-resource/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "c52d1e5eb3aae274b1fb7ebe1b16cabe233879e5", + "commit": "6696f3dd3c4f1e94fb6e92c1ef404e34bf2df58d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/resources/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/resources/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/resources/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py index 1cbbc13177245..d78176a792d96 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py index 6bcc4955dba84..eebab8817f16e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/_deployment_scripts_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +69,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DeploymentScriptsClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py index 963bdd9f69e29..435c43bb56045 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py index 4debddb3ce229..f54b3c45b762b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/aio/_deployment_scripts_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +68,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DeploymentScriptsClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py index 90d2ac95d1471..d4d4c09823149 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DeploymentScriptsClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py index 54dca0db6c664..a8b2e1e61bbd2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(DeploymentScriptsClientConfiguration, 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(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py index 27e79ed2774e9..8e27ea67e8afc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_deployment_scripts_client.py @@ -6,74 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import DeploymentScriptsClientConfiguration +from .operations import DeploymentScriptsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import DeploymentScriptsClientConfiguration -from .operations import DeploymentScriptsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class DeploymentScriptsClient(object): """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations - :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.operations.DeploymentScriptsOperations + :vartype deployment_scripts: + azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.operations.DeploymentScriptsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which 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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_scripts = DeploymentScriptsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json index 7b02d1bfc5246..b7e619d77a9a3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "DeploymentScriptsClient", "filename": "_deployment_scripts_client", "description": "The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployment_scripts": "DeploymentScriptsOperations" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py index 5d8dd151ee2e0..815170897d35d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._deployment_scripts_client import DeploymentScriptsClient __all__ = ['DeploymentScriptsClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py index 63435e88834c9..f54e3b7611571 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DeploymentScriptsClientConfiguration, 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(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py index 56a6d2b0f461a..92f85375a1a7d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_deployment_scripts_client.py @@ -6,70 +6,79 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest 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 .. import models from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class DeploymentScriptsClient(object): +class DeploymentScriptsClient: """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations - :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.aio.operations.DeploymentScriptsOperations + :vartype deployment_scripts: + azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.aio.operations.DeploymentScriptsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which 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 = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_scripts = DeploymentScriptsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_deployment_scripts_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_deployment_scripts_operations.py index 50fde68987e63..fdd026510af04 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_deployment_scripts_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/aio/operations/_deployment_scripts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_scripts_operations import build_create_request_initial, build_delete_request, build_get_logs_default_request, build_get_logs_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,39 +60,28 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(deployment_script, 'DeploymentScript') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment_script, 'DeploymentScript') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -99,8 +93,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -115,18 +112,24 @@ async def begin_create( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script supplied to the operation. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript :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. + :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 DeploymentScript or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] - :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 DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] lro_delay = kwargs.pop( 'polling_interval', @@ -138,27 +141,21 @@ async def begin_create( resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, + 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('DeploymentScript', pipeline_response) - if cls: 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - 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: @@ -170,8 +167,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -186,7 +185,8 @@ async def update( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentScript, or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript @@ -197,41 +197,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if deployment_script is not None: - body_content = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -240,8 +230,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -264,33 +257,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -299,8 +282,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -324,33 +310,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -358,6 +334,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -365,8 +343,10 @@ def list_by_subscription( """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -374,34 +354,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -414,17 +389,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore + @distributed_trace_async async def get_logs( self, resource_group_name: str, @@ -447,33 +424,23 @@ async def get_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_logs.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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLogsList', pipeline_response) @@ -482,8 +449,11 @@ async def get_logs( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore + + @distributed_trace_async async def get_logs_default( self, resource_group_name: str, @@ -511,35 +481,24 @@ async def get_logs_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_logs_default.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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(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 tail is not None: - query_parameters['tail'] = self._serialize.query("tail", tail, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_default_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + tail=tail, + template_url=self.get_logs_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLog', pipeline_response) @@ -548,8 +507,11 @@ async def get_logs_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -560,8 +522,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -569,35 +533,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -610,12 +570,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py index 8bab559ef1d84..278dc1e6bf8e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_deployment_scripts_client_enums.py @@ -6,27 +6,12 @@ # 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 CleanupOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. """ @@ -35,7 +20,7 @@ class CleanupOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ON_SUCCESS = "OnSuccess" ON_EXPIRATION = "OnExpiration" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -44,13 +29,13 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the managed identity. """ USER_ASSIGNED = "UserAssigned" -class ScriptProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the script execution. This only appears in the response. """ @@ -61,7 +46,7 @@ class ScriptProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" CANCELED = "Canceled" -class ScriptType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScriptType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the script. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models.py index a772e98f7e709..c7cb8cbca6c24 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models.py @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -61,18 +63,19 @@ class DeploymentScript(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData @@ -107,6 +110,17 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(DeploymentScript, self).__init__(**kwargs) self.identity = kwargs['identity'] self.location = kwargs['location'] @@ -128,31 +142,32 @@ class AzureCliScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -163,30 +178,30 @@ class AzureCliScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -235,6 +250,53 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScript, self).__init__(**kwargs) self.kind = 'AzureCLI' # type: str self.container_settings = kwargs.get('container_settings', None) @@ -259,28 +321,28 @@ class ScriptConfigurationBase(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta + :vartype timeout: ~datetime.timedelta """ _validation = { @@ -303,6 +365,31 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + """ super(ScriptConfigurationBase, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -319,16 +406,16 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -360,6 +447,19 @@ def __init__( self, **kwargs ): + """ + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + """ super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) self.container_settings = kwargs.get('container_settings', None) self.storage_account_settings = kwargs.get('storage_account_settings', None) @@ -376,38 +476,38 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -418,8 +518,8 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -453,6 +553,44 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScriptProperties, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -485,31 +623,32 @@ class AzurePowerShellScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -520,30 +659,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -592,6 +731,53 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScript, self).__init__(**kwargs) self.kind = 'AzurePowerShell' # type: str self.container_settings = kwargs.get('container_settings', None) @@ -618,38 +804,38 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -660,8 +846,8 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -695,6 +881,44 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScriptProperties, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -717,7 +941,7 @@ def __init__( class ContainerConfiguration(msrest.serialization.Model): """Settings to customize ACI container instance. - :param container_group_name: Container group name, if not specified then the name will get + :ivar container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention or when you want to @@ -727,7 +951,7 @@ class ContainerConfiguration(msrest.serialization.Model): object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' property. - :type container_group_name: str + :vartype container_group_name: str """ _validation = { @@ -742,6 +966,19 @@ def __init__( self, **kwargs ): + """ + :keyword container_group_name: Container group name, if not specified then the name will get + auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique + name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' + when you have an Azure Policy that expects a specific naming convention or when you want to + fully control the name. 'containerGroupName' property must be between 1 and 63 characters long, + must contain only lowercase letters, numbers, and dashes and it cannot start or end with a dash + and consecutive dashes are not allowed. To specify a 'containerGroupName', add the following + object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. + If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' + property. + :paramtype container_group_name: str + """ super(ContainerConfiguration, self).__init__(**kwargs) self.container_group_name = kwargs.get('container_group_name', None) @@ -751,8 +988,8 @@ class DeploymentScriptListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment scripts. - :type value: + :ivar value: An array of deployment scripts. + :vartype value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -771,6 +1008,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment scripts. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + """ super(DeploymentScriptListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -779,9 +1021,9 @@ def __init__( class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ _attribute_map = { @@ -792,6 +1034,12 @@ def __init__( self, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + """ super(DeploymentScriptsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -807,8 +1055,8 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param tags: A set of tags. Resource tags to be updated. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags to be updated. + :vartype tags: dict[str, str] """ _validation = { @@ -828,6 +1076,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags to be updated. + :paramtype tags: dict[str, str] + """ super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -837,12 +1089,12 @@ class EnvironmentVariable(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the environment variable. - :type name: str - :param value: The value of the environment variable. - :type value: str - :param secure_value: The value of the secure environment variable. - :type secure_value: str + :ivar name: Required. The name of the environment variable. + :vartype name: str + :ivar value: The value of the environment variable. + :vartype value: str + :ivar secure_value: The value of the secure environment variable. + :vartype secure_value: str """ _validation = { @@ -859,6 +1111,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the environment variable. + :paramtype name: str + :keyword value: The value of the environment variable. + :paramtype value: str + :keyword secure_value: The value of the secure environment variable. + :paramtype secure_value: str + """ super(EnvironmentVariable, self).__init__(**kwargs) self.name = kwargs['name'] self.value = kwargs.get('value', None) @@ -890,6 +1150,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -934,6 +1196,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -947,14 +1211,14 @@ class ManagedServiceIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of the managed identity. Possible values include: "UserAssigned". - :type type: str or + :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. :vartype tenant_id: str - :param user_assigned_identities: The list of user-assigned managed identities associated with + :ivar user_assigned_identities: The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed identity. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.UserAssignedIdentity] """ @@ -972,6 +1236,15 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :paramtype type: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.UserAssignedIdentity] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.tenant_id = None @@ -1011,6 +1284,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScriptLog, self).__init__(**kwargs) self.log = None @@ -1018,8 +1293,9 @@ def __init__( class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. - :param value: Deployment scripts logs. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] + :ivar value: Deployment scripts logs. + :vartype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] """ _attribute_map = { @@ -1030,6 +1306,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: Deployment scripts logs. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] + """ super(ScriptLogsList, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -1049,8 +1330,8 @@ class ScriptStatus(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. :vartype expiration_time: ~datetime.datetime - :param error: Error that is relayed from the script execution. - :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + :ivar error: Error that is relayed from the script execution. + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ _validation = { @@ -1074,6 +1355,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: Error that is relayed from the script execution. + :paramtype error: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + """ super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -1086,10 +1372,10 @@ def __init__( class StorageAccountConfiguration(msrest.serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. - :param storage_account_name: The storage account name. - :type storage_account_name: str - :param storage_account_key: The storage account access key. - :type storage_account_key: str + :ivar storage_account_name: The storage account name. + :vartype storage_account_name: str + :ivar storage_account_key: The storage account access key. + :vartype storage_account_key: str """ _attribute_map = { @@ -1101,6 +1387,12 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_name: The storage account name. + :paramtype storage_account_name: str + :keyword storage_account_key: The storage account access key. + :paramtype storage_account_key: str + """ super(StorageAccountConfiguration, self).__init__(**kwargs) self.storage_account_name = kwargs.get('storage_account_name', None) self.storage_account_key = kwargs.get('storage_account_key', None) @@ -1109,22 +1401,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1140,6 +1432,24 @@ def __init__( self, **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.resource.deploymentscripts.v2019_10_01_preview.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.resource.deploymentscripts.v2019_10_01_preview.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -1174,6 +1484,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py index a6440ff343ea8..c84be9388f677 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/models/_models_py3.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -66,18 +68,19 @@ class DeploymentScript(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData @@ -116,6 +119,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(DeploymentScript, self).__init__(**kwargs) self.identity = identity self.location = location @@ -137,31 +151,32 @@ class AzureCliScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -172,30 +187,30 @@ class AzureCliScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -260,6 +275,53 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) self.kind = 'AzureCLI' # type: str self.container_settings = container_settings @@ -284,28 +346,28 @@ class ScriptConfigurationBase(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta + :vartype timeout: ~datetime.timedelta """ _validation = { @@ -337,6 +399,31 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + """ super(ScriptConfigurationBase, self).__init__(**kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -353,16 +440,16 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -398,6 +485,19 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + """ super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) self.container_settings = container_settings self.storage_account_settings = storage_account_settings @@ -414,38 +514,38 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -456,8 +556,8 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -504,6 +604,44 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -536,31 +674,32 @@ class AzurePowerShellScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Required. Managed identity to be used for this deployment script. Currently, + :ivar identity: Required. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType + :vartype kind: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -571,30 +710,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -659,6 +798,53 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) self.kind = 'AzurePowerShell' # type: str self.container_settings = container_settings @@ -685,38 +871,38 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -727,8 +913,8 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -775,6 +961,44 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CleanupOptions + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -797,7 +1021,7 @@ def __init__( class ContainerConfiguration(msrest.serialization.Model): """Settings to customize ACI container instance. - :param container_group_name: Container group name, if not specified then the name will get + :ivar container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention or when you want to @@ -807,7 +1031,7 @@ class ContainerConfiguration(msrest.serialization.Model): object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' property. - :type container_group_name: str + :vartype container_group_name: str """ _validation = { @@ -824,6 +1048,19 @@ def __init__( container_group_name: Optional[str] = None, **kwargs ): + """ + :keyword container_group_name: Container group name, if not specified then the name will get + auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique + name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' + when you have an Azure Policy that expects a specific naming convention or when you want to + fully control the name. 'containerGroupName' property must be between 1 and 63 characters long, + must contain only lowercase letters, numbers, and dashes and it cannot start or end with a dash + and consecutive dashes are not allowed. To specify a 'containerGroupName', add the following + object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. + If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' + property. + :paramtype container_group_name: str + """ super(ContainerConfiguration, self).__init__(**kwargs) self.container_group_name = container_group_name @@ -833,8 +1070,8 @@ class DeploymentScriptListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment scripts. - :type value: + :ivar value: An array of deployment scripts. + :vartype value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -855,6 +1092,11 @@ def __init__( value: Optional[List["DeploymentScript"]] = None, **kwargs ): + """ + :keyword value: An array of deployment scripts. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + """ super(DeploymentScriptListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -863,9 +1105,9 @@ def __init__( class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ _attribute_map = { @@ -878,6 +1120,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + """ super(DeploymentScriptsError, self).__init__(**kwargs) self.error = error @@ -893,8 +1141,8 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param tags: A set of tags. Resource tags to be updated. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags to be updated. + :vartype tags: dict[str, str] """ _validation = { @@ -916,6 +1164,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags to be updated. + :paramtype tags: dict[str, str] + """ super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) self.tags = tags @@ -925,12 +1177,12 @@ class EnvironmentVariable(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the environment variable. - :type name: str - :param value: The value of the environment variable. - :type value: str - :param secure_value: The value of the secure environment variable. - :type secure_value: str + :ivar name: Required. The name of the environment variable. + :vartype name: str + :ivar value: The value of the environment variable. + :vartype value: str + :ivar secure_value: The value of the secure environment variable. + :vartype secure_value: str """ _validation = { @@ -951,6 +1203,14 @@ def __init__( secure_value: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the environment variable. + :paramtype name: str + :keyword value: The value of the environment variable. + :paramtype value: str + :keyword secure_value: The value of the secure environment variable. + :paramtype secure_value: str + """ super(EnvironmentVariable, self).__init__(**kwargs) self.name = name self.value = value @@ -982,6 +1242,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1026,6 +1288,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1039,14 +1303,14 @@ class ManagedServiceIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of the managed identity. Possible values include: "UserAssigned". - :type type: str or + :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. :vartype tenant_id: str - :param user_assigned_identities: The list of user-assigned managed identities associated with + :ivar user_assigned_identities: The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed identity. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.UserAssignedIdentity] """ @@ -1067,6 +1331,15 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :paramtype type: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.UserAssignedIdentity] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.type = type self.tenant_id = None @@ -1106,6 +1379,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScriptLog, self).__init__(**kwargs) self.log = None @@ -1113,8 +1388,9 @@ def __init__( class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. - :param value: Deployment scripts logs. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] + :ivar value: Deployment scripts logs. + :vartype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] """ _attribute_map = { @@ -1127,6 +1403,11 @@ def __init__( value: Optional[List["ScriptLog"]] = None, **kwargs ): + """ + :keyword value: Deployment scripts logs. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ScriptLog] + """ super(ScriptLogsList, self).__init__(**kwargs) self.value = value @@ -1146,8 +1427,8 @@ class ScriptStatus(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. :vartype expiration_time: ~datetime.datetime - :param error: Error that is relayed from the script execution. - :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + :ivar error: Error that is relayed from the script execution. + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse """ _validation = { @@ -1173,6 +1454,11 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Error that is relayed from the script execution. + :paramtype error: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.ErrorResponse + """ super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -1185,10 +1471,10 @@ def __init__( class StorageAccountConfiguration(msrest.serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. - :param storage_account_name: The storage account name. - :type storage_account_name: str - :param storage_account_key: The storage account access key. - :type storage_account_key: str + :ivar storage_account_name: The storage account name. + :vartype storage_account_name: str + :ivar storage_account_key: The storage account access key. + :vartype storage_account_key: str """ _attribute_map = { @@ -1203,6 +1489,12 @@ def __init__( storage_account_key: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_name: The storage account name. + :paramtype storage_account_name: str + :keyword storage_account_key: The storage account access key. + :paramtype storage_account_key: str + """ super(StorageAccountConfiguration, self).__init__(**kwargs) self.storage_account_name = storage_account_name self.storage_account_key = storage_account_key @@ -1211,22 +1503,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1249,6 +1541,24 @@ def __init__( 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.resource.deploymentscripts.v2019_10_01_preview.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.resource.deploymentscripts.v2019_10_01_preview.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 @@ -1283,6 +1593,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_deployment_scripts_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_deployment_scripts_operations.py index 58aa817bb0aad..b3ef6be72045a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_deployment_scripts_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_01_preview/operations/_deployment_scripts_operations.py @@ -5,26 +5,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts') + 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 + ) + + +def build_get_logs_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_logs_default_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + tail = kwargs.pop('tail', None) # type: Optional[int] + + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default') + 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\._\(\)]+$'), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_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 tail is not None: + query_parameters['tail'] = _SERIALIZER.query("tail", tail, 'int') + + # 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( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts') + 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\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class DeploymentScriptsOperations(object): """DeploymentScriptsOperations operations. @@ -60,39 +362,28 @@ def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(deployment_script, 'DeploymentScript') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment_script, 'DeploymentScript') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -104,8 +395,11 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def begin_create( self, resource_group_name, # type: str @@ -121,18 +415,24 @@ def begin_create( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script supplied to the operation. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript :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. + :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 DeploymentScript or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] - :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 DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] lro_delay = kwargs.pop( 'polling_interval', @@ -144,27 +444,21 @@ def begin_create( resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, + 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('DeploymentScript', pipeline_response) - if cls: 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - 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: @@ -176,8 +470,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + @distributed_trace def update( self, resource_group_name, # type: str @@ -193,7 +489,8 @@ def update( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptUpdateParameter :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentScript, or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScript @@ -204,41 +501,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if deployment_script is not None: - body_content = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -247,8 +534,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -272,33 +562,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -307,8 +587,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -333,33 +616,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -367,6 +640,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -375,8 +650,10 @@ def list_by_subscription( """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -384,34 +661,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -424,17 +696,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore + @distributed_trace def get_logs( self, resource_group_name, # type: str @@ -458,33 +732,23 @@ def get_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_logs.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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLogsList', pipeline_response) @@ -493,8 +757,11 @@ def get_logs( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore + + @distributed_trace def get_logs_default( self, resource_group_name, # type: str @@ -523,35 +790,24 @@ def get_logs_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_logs_default.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\._\(\)]+$'), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(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 tail is not None: - query_parameters['tail'] = self._serialize.query("tail", tail, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_default_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + tail=tail, + template_url=self.get_logs_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLog', pipeline_response) @@ -560,8 +816,11 @@ def get_logs_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -573,8 +832,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_01_preview.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -582,35 +843,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -623,12 +880,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py index 90d2ac95d1471..d4d4c09823149 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['DeploymentScriptsClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py index 4155495f038ae..149adfdcd15fc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(DeploymentScriptsClientConfiguration, 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(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py index 55e1f86965c8d..b5fa299df24f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_deployment_scripts_client.py @@ -6,74 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import DeploymentScriptsClientConfiguration +from .operations import DeploymentScriptsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import DeploymentScriptsClientConfiguration -from .operations import DeploymentScriptsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class DeploymentScriptsClient(object): """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations - :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2020_10_01.operations.DeploymentScriptsOperations + :vartype deployment_scripts: + azure.mgmt.resource.deploymentscripts.v2020_10_01.operations.DeploymentScriptsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which 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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_scripts = DeploymentScriptsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json index 13ceeb6c7ef5e..4b3e7a96d9913 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_metadata.json @@ -5,13 +5,13 @@ "name": "DeploymentScriptsClient", "filename": "_deployment_scripts_client", "description": "The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DeploymentScriptsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployment_scripts": "DeploymentScriptsOperations" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py index 5d8dd151ee2e0..815170897d35d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._deployment_scripts_client import DeploymentScriptsClient __all__ = ['DeploymentScriptsClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py index 83f2a40be5e1a..65757bc3ad08a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(DeploymentScriptsClientConfiguration, 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(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py index 716e7d98d4020..7d10bda166d92 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_deployment_scripts_client.py @@ -6,70 +6,79 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest 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 .. import models from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class DeploymentScriptsClient(object): +class DeploymentScriptsClient: """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. :ivar deployment_scripts: DeploymentScriptsOperations operations - :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2020_10_01.aio.operations.DeploymentScriptsOperations + :vartype deployment_scripts: + azure.mgmt.resource.deploymentscripts.v2020_10_01.aio.operations.DeploymentScriptsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which 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 = DeploymentScriptsClientConfiguration(credential, subscription_id, **kwargs) + self._config = DeploymentScriptsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployment_scripts = DeploymentScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployment_scripts = DeploymentScriptsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_deployment_scripts_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_deployment_scripts_operations.py index cc586d9a00a9a..d6ee3318b6818 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_deployment_scripts_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/aio/operations/_deployment_scripts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_scripts_operations import build_create_request_initial, build_delete_request, build_get_logs_default_request, build_get_logs_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,39 +60,28 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - '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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(deployment_script, 'DeploymentScript') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment_script, 'DeploymentScript') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -99,8 +93,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -115,18 +112,24 @@ async def begin_create( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script supplied to the operation. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript :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. + :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 DeploymentScript or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] - :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 DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] lro_delay = kwargs.pop( 'polling_interval', @@ -138,27 +141,21 @@ async def begin_create( resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, + 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('DeploymentScript', pipeline_response) - if cls: 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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - 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: @@ -170,8 +167,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -186,7 +185,8 @@ async def update( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentScript, or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript @@ -197,41 +197,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if deployment_script is not None: - body_content = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -240,8 +230,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -264,33 +257,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -299,8 +282,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -324,33 +310,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -358,6 +334,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -365,8 +343,10 @@ def list_by_subscription( """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -374,34 +354,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -414,17 +389,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore + @distributed_trace_async async def get_logs( self, resource_group_name: str, @@ -447,33 +424,23 @@ async def get_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_logs.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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLogsList', pipeline_response) @@ -482,8 +449,11 @@ async def get_logs( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore + + @distributed_trace_async async def get_logs_default( self, resource_group_name: str, @@ -511,35 +481,24 @@ async def get_logs_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_logs_default.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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(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 tail is not None: - query_parameters['tail'] = self._serialize.query("tail", tail, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_default_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + tail=tail, + template_url=self.get_logs_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLog', pipeline_response) @@ -548,8 +507,11 @@ async def get_logs_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -560,8 +522,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -569,35 +533,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - '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), - } - url = self._client.format_url(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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -610,12 +570,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py index 8bab559ef1d84..278dc1e6bf8e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_deployment_scripts_client_enums.py @@ -6,27 +6,12 @@ # 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 CleanupOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CleanupOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. """ @@ -35,7 +20,7 @@ class CleanupOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ON_SUCCESS = "OnSuccess" ON_EXPIRATION = "OnExpiration" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -44,13 +29,13 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the managed identity. """ USER_ASSIGNED = "UserAssigned" -class ScriptProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScriptProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the script execution. This only appears in the response. """ @@ -61,7 +46,7 @@ class ScriptProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" CANCELED = "Canceled" -class ScriptType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScriptType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the script. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models.py index df8f0fa3075c9..105c5c37060f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models.py @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -61,18 +63,18 @@ class DeploymentScript(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData """ @@ -105,6 +107,17 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(DeploymentScript, self).__init__(**kwargs) self.identity = kwargs.get('identity', None) self.location = kwargs['location'] @@ -126,30 +139,30 @@ class AzureCliScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -160,30 +173,30 @@ class AzureCliScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -230,6 +243,53 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScript, self).__init__(**kwargs) self.kind = 'AzureCLI' # type: str self.container_settings = kwargs.get('container_settings', None) @@ -254,28 +314,28 @@ class ScriptConfigurationBase(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta + :vartype timeout: ~datetime.timedelta """ _validation = { @@ -297,6 +357,31 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + """ super(ScriptConfigurationBase, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -313,16 +398,16 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -354,6 +439,19 @@ def __init__( self, **kwargs ): + """ + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + """ super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) self.container_settings = kwargs.get('container_settings', None) self.storage_account_settings = kwargs.get('storage_account_settings', None) @@ -370,38 +468,38 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -412,8 +510,8 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -446,6 +544,44 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScriptProperties, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -478,30 +614,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -512,30 +648,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -582,6 +718,53 @@ def __init__( self, **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScript, self).__init__(**kwargs) self.kind = 'AzurePowerShell' # type: str self.container_settings = kwargs.get('container_settings', None) @@ -608,38 +791,38 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -650,8 +833,8 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -684,6 +867,44 @@ def __init__( self, **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScriptProperties, self).__init__(**kwargs) self.primary_script_uri = kwargs.get('primary_script_uri', None) self.supporting_script_uris = kwargs.get('supporting_script_uris', None) @@ -706,7 +927,7 @@ def __init__( class ContainerConfiguration(msrest.serialization.Model): """Settings to customize ACI container instance. - :param container_group_name: Container group name, if not specified then the name will get + :ivar container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention or when you want to @@ -716,7 +937,7 @@ class ContainerConfiguration(msrest.serialization.Model): object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' property. - :type container_group_name: str + :vartype container_group_name: str """ _validation = { @@ -731,6 +952,19 @@ def __init__( self, **kwargs ): + """ + :keyword container_group_name: Container group name, if not specified then the name will get + auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique + name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' + when you have an Azure Policy that expects a specific naming convention or when you want to + fully control the name. 'containerGroupName' property must be between 1 and 63 characters long, + must contain only lowercase letters, numbers, and dashes and it cannot start or end with a dash + and consecutive dashes are not allowed. To specify a 'containerGroupName', add the following + object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. + If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' + property. + :paramtype container_group_name: str + """ super(ContainerConfiguration, self).__init__(**kwargs) self.container_group_name = kwargs.get('container_group_name', None) @@ -740,8 +974,9 @@ class DeploymentScriptListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment scripts. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :ivar value: An array of deployment scripts. + :vartype value: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -759,6 +994,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment scripts. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + """ super(DeploymentScriptListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -767,9 +1007,9 @@ def __init__( class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -780,6 +1020,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + """ super(DeploymentScriptsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -795,8 +1040,8 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param tags: A set of tags. Resource tags to be updated. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags to be updated. + :vartype tags: dict[str, str] """ _validation = { @@ -816,6 +1061,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags to be updated. + :paramtype tags: dict[str, str] + """ super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -825,12 +1074,12 @@ class EnvironmentVariable(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the environment variable. - :type name: str - :param value: The value of the environment variable. - :type value: str - :param secure_value: The value of the secure environment variable. - :type secure_value: str + :ivar name: Required. The name of the environment variable. + :vartype name: str + :ivar value: The value of the environment variable. + :vartype value: str + :ivar secure_value: The value of the secure environment variable. + :vartype secure_value: str """ _validation = { @@ -847,6 +1096,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the environment variable. + :paramtype name: str + :keyword value: The value of the environment variable. + :paramtype value: str + :keyword secure_value: The value of the secure environment variable. + :paramtype secure_value: str + """ super(EnvironmentVariable, self).__init__(**kwargs) self.name = kwargs['name'] self.value = kwargs.get('value', None) @@ -878,6 +1135,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -921,6 +1180,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -934,14 +1195,14 @@ class ManagedServiceIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of the managed identity. Possible values include: "UserAssigned". - :type type: str or + :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. :vartype tenant_id: str - :param user_assigned_identities: The list of user-assigned managed identities associated with + :ivar user_assigned_identities: The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed identity. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.UserAssignedIdentity] """ @@ -959,6 +1220,15 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :paramtype type: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.UserAssignedIdentity] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.tenant_id = None @@ -998,6 +1268,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScriptLog, self).__init__(**kwargs) self.log = None @@ -1005,8 +1277,8 @@ def __init__( class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. - :param value: Deployment scripts logs. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] + :ivar value: Deployment scripts logs. + :vartype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] """ _attribute_map = { @@ -1017,6 +1289,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Deployment scripts logs. + :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] + """ super(ScriptLogsList, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -1036,8 +1312,8 @@ class ScriptStatus(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. :vartype expiration_time: ~datetime.datetime - :param error: Error that is relayed from the script execution. - :type error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + :ivar error: Error that is relayed from the script execution. + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ _validation = { @@ -1061,6 +1337,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: Error that is relayed from the script execution. + :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + """ super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -1073,10 +1353,10 @@ def __init__( class StorageAccountConfiguration(msrest.serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. - :param storage_account_name: The storage account name. - :type storage_account_name: str - :param storage_account_key: The storage account access key. - :type storage_account_key: str + :ivar storage_account_name: The storage account name. + :vartype storage_account_name: str + :ivar storage_account_key: The storage account access key. + :vartype storage_account_key: str """ _attribute_map = { @@ -1088,6 +1368,12 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_name: The storage account name. + :paramtype storage_account_name: str + :keyword storage_account_key: The storage account access key. + :paramtype storage_account_key: str + """ super(StorageAccountConfiguration, self).__init__(**kwargs) self.storage_account_name = kwargs.get('storage_account_name', None) self.storage_account_key = kwargs.get('storage_account_key', None) @@ -1096,22 +1382,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.deploymentscripts.v2020_10_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1127,6 +1413,24 @@ def __init__( self, **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.resource.deploymentscripts.v2020_10_01.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.resource.deploymentscripts.v2020_10_01.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -1161,6 +1465,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py index 9364dcdd96426..6576177a78cab 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/models/_models_py3.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -66,18 +68,18 @@ class DeploymentScript(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData """ @@ -114,6 +116,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(DeploymentScript, self).__init__(**kwargs) self.identity = identity self.location = location @@ -135,30 +148,30 @@ class AzureCliScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -169,30 +182,30 @@ class AzureCliScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -255,6 +268,53 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) self.kind = 'AzureCLI' # type: str self.container_settings = container_settings @@ -279,28 +339,28 @@ class ScriptConfigurationBase(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta + :vartype timeout: ~datetime.timedelta """ _validation = { @@ -331,6 +391,31 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + """ super(ScriptConfigurationBase, self).__init__(**kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -347,16 +432,16 @@ class DeploymentScriptPropertiesBase(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -392,6 +477,19 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + """ super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) self.container_settings = container_settings self.storage_account_settings = storage_account_settings @@ -408,38 +506,38 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -450,8 +548,8 @@ class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurati :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_cli_version: Required. Azure CLI module version to be used. - :type az_cli_version: str + :ivar az_cli_version: Required. Azure CLI module version to be used. + :vartype az_cli_version: str """ _validation = { @@ -497,6 +595,44 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword az_cli_version: Required. Azure CLI module version to be used. + :paramtype az_cli_version: str + """ super(AzureCliScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -529,30 +665,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param identity: Optional property. Managed identity to be used for this deployment script. + :ivar identity: Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. - :type identity: + :vartype identity: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account for the deployment + :ivar location: Required. The location of the ACI and the storage account for the deployment script. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: Required. Type of the script.Constant filled by server. Possible values include: + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Required. Type of the script.Constant filled by server. Possible values include: "AzurePowerShell", "AzureCLI". - :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType + :vartype kind: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptType :ivar system_data: The system metadata related to this resource. :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.SystemData - :param container_settings: Container settings. - :type container_settings: + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -563,30 +699,30 @@ class AzurePowerShellScript(DeploymentScript): :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :vartype timeout: ~datetime.timedelta + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -649,6 +785,53 @@ def __init__( timeout: Optional[datetime.timedelta] = "P1D", **kwargs ): + """ + :keyword identity: Optional property. Managed identity to be used for this deployment script. + Currently, only user-assigned MSI is supported. + :paramtype identity: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentity + :keyword location: Required. The location of the ACI and the storage account for the deployment + script. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) self.kind = 'AzurePowerShell' # type: str self.container_settings = container_settings @@ -675,38 +858,38 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf All required parameters must be populated in order to send to Azure. - :param primary_script_uri: Uri for the script. This is the entry point for the external script. - :type primary_script_uri: str - :param supporting_script_uris: Supporting files for the external script. - :type supporting_script_uris: list[str] - :param script_content: Script body. - :type script_content: str - :param arguments: Command line arguments to pass to the script. Arguments are separated by + :ivar primary_script_uri: Uri for the script. This is the entry point for the external script. + :vartype primary_script_uri: str + :ivar supporting_script_uris: Supporting files for the external script. + :vartype supporting_script_uris: list[str] + :ivar script_content: Script body. + :vartype script_content: str + :ivar arguments: Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'. - :type arguments: str - :param environment_variables: The environment variables to pass over to the script. - :type environment_variables: + :vartype arguments: str + :ivar environment_variables: The environment variables to pass over to the script. + :vartype environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] - :param force_update_tag: Gets or sets how the deployment script should be forced to execute - even if the script resource has not changed. Can be current time stamp or a GUID. - :type force_update_tag: str - :param retention_interval: Required. Interval for which the service retains the script resource + :ivar force_update_tag: Gets or sets how the deployment script should be forced to execute even + if the script resource has not changed. Can be current time stamp or a GUID. + :vartype force_update_tag: str + :ivar retention_interval: Required. Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - :type retention_interval: ~datetime.timedelta - :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + :vartype retention_interval: ~datetime.timedelta + :ivar timeout: Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D. - :type timeout: ~datetime.timedelta - :param container_settings: Container settings. - :type container_settings: + :vartype timeout: ~datetime.timedelta + :ivar container_settings: Container settings. + :vartype container_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration - :param storage_account_settings: Storage Account settings. - :type storage_account_settings: + :ivar storage_account_settings: Storage Account settings. + :vartype storage_account_settings: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration - :param cleanup_preference: The clean up preference when the script execution gets in a terminal + :ivar cleanup_preference: The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", "OnExpiration". Default value: "Always". - :type cleanup_preference: str or + :vartype cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions :ivar provisioning_state: State of the script execution. This only appears in the response. Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", @@ -717,8 +900,8 @@ class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConf :vartype status: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, any] - :param az_power_shell_version: Required. Azure PowerShell module version to be used. - :type az_power_shell_version: str + :ivar az_power_shell_version: Required. Azure PowerShell module version to be used. + :vartype az_power_shell_version: str """ _validation = { @@ -764,6 +947,44 @@ def __init__( cleanup_preference: Optional[Union[str, "CleanupOptions"]] = "Always", **kwargs ): + """ + :keyword primary_script_uri: Uri for the script. This is the entry point for the external + script. + :paramtype primary_script_uri: str + :keyword supporting_script_uris: Supporting files for the external script. + :paramtype supporting_script_uris: list[str] + :keyword script_content: Script body. + :paramtype script_content: str + :keyword arguments: Command line arguments to pass to the script. Arguments are separated by + spaces. ex: -Name blue* -Location 'West US 2'. + :paramtype arguments: str + :keyword environment_variables: The environment variables to pass over to the script. + :paramtype environment_variables: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.EnvironmentVariable] + :keyword force_update_tag: Gets or sets how the deployment script should be forced to execute + even if the script resource has not changed. Can be current time stamp or a GUID. + :paramtype force_update_tag: str + :keyword retention_interval: Required. Interval for which the service retains the script + resource after it reaches a terminal state. Resource will be deleted when this duration + expires. Duration is based on ISO 8601 pattern (for example P1D means one day). + :paramtype retention_interval: ~datetime.timedelta + :keyword timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is P1D. + :paramtype timeout: ~datetime.timedelta + :keyword container_settings: Container settings. + :paramtype container_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ContainerConfiguration + :keyword storage_account_settings: Storage Account settings. + :paramtype storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.StorageAccountConfiguration + :keyword cleanup_preference: The clean up preference when the script execution gets in a + terminal state. Default setting is 'Always'. Possible values include: "Always", "OnSuccess", + "OnExpiration". Default value: "Always". + :paramtype cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CleanupOptions + :keyword az_power_shell_version: Required. Azure PowerShell module version to be used. + :paramtype az_power_shell_version: str + """ super(AzurePowerShellScriptProperties, self).__init__(container_settings=container_settings, storage_account_settings=storage_account_settings, cleanup_preference=cleanup_preference, primary_script_uri=primary_script_uri, supporting_script_uris=supporting_script_uris, script_content=script_content, arguments=arguments, environment_variables=environment_variables, force_update_tag=force_update_tag, retention_interval=retention_interval, timeout=timeout, **kwargs) self.primary_script_uri = primary_script_uri self.supporting_script_uris = supporting_script_uris @@ -786,7 +1007,7 @@ def __init__( class ContainerConfiguration(msrest.serialization.Model): """Settings to customize ACI container instance. - :param container_group_name: Container group name, if not specified then the name will get + :ivar container_group_name: Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention or when you want to @@ -796,7 +1017,7 @@ class ContainerConfiguration(msrest.serialization.Model): object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' property. - :type container_group_name: str + :vartype container_group_name: str """ _validation = { @@ -813,6 +1034,19 @@ def __init__( container_group_name: Optional[str] = None, **kwargs ): + """ + :keyword container_group_name: Container group name, if not specified then the name will get + auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique + name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' + when you have an Azure Policy that expects a specific naming convention or when you want to + fully control the name. 'containerGroupName' property must be between 1 and 63 characters long, + must contain only lowercase letters, numbers, and dashes and it cannot start or end with a dash + and consecutive dashes are not allowed. To specify a 'containerGroupName', add the following + object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. + If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' + property. + :paramtype container_group_name: str + """ super(ContainerConfiguration, self).__init__(**kwargs) self.container_group_name = container_group_name @@ -822,8 +1056,9 @@ class DeploymentScriptListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment scripts. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :ivar value: An array of deployment scripts. + :vartype value: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -843,6 +1078,11 @@ def __init__( value: Optional[List["DeploymentScript"]] = None, **kwargs ): + """ + :keyword value: An array of deployment scripts. + :paramtype value: + list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + """ super(DeploymentScriptListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -851,9 +1091,9 @@ def __init__( class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -866,6 +1106,11 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + """ super(DeploymentScriptsError, self).__init__(**kwargs) self.error = error @@ -881,8 +1126,8 @@ class DeploymentScriptUpdateParameter(AzureResourceBase): :vartype name: str :ivar type: Type of this resource. :vartype type: str - :param tags: A set of tags. Resource tags to be updated. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags to be updated. + :vartype tags: dict[str, str] """ _validation = { @@ -904,6 +1149,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags to be updated. + :paramtype tags: dict[str, str] + """ super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) self.tags = tags @@ -913,12 +1162,12 @@ class EnvironmentVariable(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the environment variable. - :type name: str - :param value: The value of the environment variable. - :type value: str - :param secure_value: The value of the secure environment variable. - :type secure_value: str + :ivar name: Required. The name of the environment variable. + :vartype name: str + :ivar value: The value of the environment variable. + :vartype value: str + :ivar secure_value: The value of the secure environment variable. + :vartype secure_value: str """ _validation = { @@ -939,6 +1188,14 @@ def __init__( secure_value: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the environment variable. + :paramtype name: str + :keyword value: The value of the environment variable. + :paramtype value: str + :keyword secure_value: The value of the secure environment variable. + :paramtype secure_value: str + """ super(EnvironmentVariable, self).__init__(**kwargs) self.name = name self.value = value @@ -970,6 +1227,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1013,6 +1272,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1026,14 +1287,14 @@ class ManagedServiceIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param type: Type of the managed identity. Possible values include: "UserAssigned". - :type type: str or + :ivar type: Type of the managed identity. Possible values include: "UserAssigned". + :vartype type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType :ivar tenant_id: ID of the Azure Active Directory. :vartype tenant_id: str - :param user_assigned_identities: The list of user-assigned managed identities associated with + :ivar user_assigned_identities: The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed identity. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.UserAssignedIdentity] """ @@ -1054,6 +1315,15 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: Type of the managed identity. Possible values include: "UserAssigned". + :paramtype type: str or + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.UserAssignedIdentity] + """ super(ManagedServiceIdentity, self).__init__(**kwargs) self.type = type self.tenant_id = None @@ -1093,6 +1363,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScriptLog, self).__init__(**kwargs) self.log = None @@ -1100,8 +1372,8 @@ def __init__( class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. - :param value: Deployment scripts logs. - :type value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] + :ivar value: Deployment scripts logs. + :vartype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] """ _attribute_map = { @@ -1114,6 +1386,10 @@ def __init__( value: Optional[List["ScriptLog"]] = None, **kwargs ): + """ + :keyword value: Deployment scripts logs. + :paramtype value: list[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ScriptLog] + """ super(ScriptLogsList, self).__init__(**kwargs) self.value = value @@ -1133,8 +1409,8 @@ class ScriptStatus(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. :vartype expiration_time: ~datetime.datetime - :param error: Error that is relayed from the script execution. - :type error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + :ivar error: Error that is relayed from the script execution. + :vartype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse """ _validation = { @@ -1160,6 +1436,10 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Error that is relayed from the script execution. + :paramtype error: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.ErrorResponse + """ super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -1172,10 +1452,10 @@ def __init__( class StorageAccountConfiguration(msrest.serialization.Model): """Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage. - :param storage_account_name: The storage account name. - :type storage_account_name: str - :param storage_account_key: The storage account access key. - :type storage_account_key: str + :ivar storage_account_name: The storage account name. + :vartype storage_account_name: str + :ivar storage_account_key: The storage account access key. + :vartype storage_account_key: str """ _attribute_map = { @@ -1190,6 +1470,12 @@ def __init__( storage_account_key: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_name: The storage account name. + :paramtype storage_account_name: str + :keyword storage_account_key: The storage account access key. + :paramtype storage_account_key: str + """ super(StorageAccountConfiguration, self).__init__(**kwargs) self.storage_account_name = storage_account_name self.storage_account_key = storage_account_key @@ -1198,22 +1484,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.deploymentscripts.v2020_10_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1236,6 +1522,24 @@ def __init__( 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.resource.deploymentscripts.v2020_10_01.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.resource.deploymentscripts.v2020_10_01.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 @@ -1270,6 +1574,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_deployment_scripts_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_deployment_scripts_operations.py index 41beba8c8eef3..bf2be1b21a612 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_deployment_scripts_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2020_10_01/operations/_deployment_scripts_operations.py @@ -5,26 +5,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts') + 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 + ) + + +def build_get_logs_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_logs_default_request( + subscription_id, # type: str + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + tail = kwargs.pop('tail', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default') + 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), + "scriptName": _SERIALIZER.url("script_name", script_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_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 tail is not None: + query_parameters['tail'] = _SERIALIZER.query("tail", tail, 'int') + + # 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( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class DeploymentScriptsOperations(object): """DeploymentScriptsOperations operations. @@ -60,39 +362,28 @@ def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - '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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(deployment_script, 'DeploymentScript') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(deployment_script, 'DeploymentScript') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -104,8 +395,11 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def begin_create( self, resource_group_name, # type: str @@ -121,18 +415,24 @@ def begin_create( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script supplied to the operation. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript :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. + :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 DeploymentScript or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] - :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 DeploymentScript or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScript"] lro_delay = kwargs.pop( 'polling_interval', @@ -144,27 +444,21 @@ def begin_create( resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, + 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('DeploymentScript', pipeline_response) - if cls: 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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - 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: @@ -176,8 +470,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + @distributed_trace def update( self, resource_group_name, # type: str @@ -193,7 +489,8 @@ def update( :param script_name: Name of the deployment script. :type script_name: str :param deployment_script: Deployment script resource with the tags to be updated. - :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter + :type deployment_script: + ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptUpdateParameter :keyword callable cls: A custom type or function that will be passed the direct response :return: DeploymentScript, or the result of cls(response) :rtype: ~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScript @@ -204,41 +501,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if deployment_script is not None: - body_content = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + _json = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -247,8 +534,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -272,33 +562,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeploymentScript', pipeline_response) @@ -307,8 +587,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -333,33 +616,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -367,6 +640,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -375,8 +650,10 @@ def list_by_subscription( """Lists all deployment scripts for a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -384,34 +661,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -424,17 +696,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore + @distributed_trace def get_logs( self, resource_group_name, # type: str @@ -458,33 +732,23 @@ def get_logs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_logs.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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + template_url=self.get_logs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLogsList', pipeline_response) @@ -493,8 +757,11 @@ def get_logs( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore + + @distributed_trace def get_logs_default( self, resource_group_name, # type: str @@ -523,35 +790,24 @@ def get_logs_default( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_logs_default.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), - 'scriptName': self._serialize.url("script_name", script_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(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 tail is not None: - query_parameters['tail'] = self._serialize.query("tail", tail, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_logs_default_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + script_name=script_name, + tail=tail, + template_url=self.get_logs_default.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScriptLog', pipeline_response) @@ -560,8 +816,11 @@ def get_logs_default( return cls(pipeline_response, deserialized, {}) return deserialized + get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -573,8 +832,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentScriptListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] + :return: An iterator like instance of either DeploymentScriptListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2020_10_01.models.DeploymentScriptListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentScriptListResult"] @@ -582,35 +843,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - '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), - } - url = self._client.format_url(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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + deserialized = self._deserialize("DeploymentScriptListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -623,12 +880,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DeploymentScriptsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py index 62a4ea7276e5a..969dd1968a096 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py index c19931ccfb59d..c5997420d9c2f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_feature_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +69,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = FeatureClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(FeatureClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py index ef9f0f49fb219..aaebaf1b44af8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/_operations_mixin.py @@ -10,17 +10,12 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + from typing import Any, Iterable + + from azure.core.paging import ItemPaged class FeatureClientOperationsMixin(object): @@ -29,11 +24,13 @@ def list_operations( self, **kwargs # type: Any ): + # type: (...) -> Iterable["_models.OperationListResult"] """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('list_operations') diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py index 81885c1a79aa1..c5904ebd7c9a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py index 4e8c576956d81..7d8191f1445bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_feature_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +68,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = FeatureClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(FeatureClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py index 568560a15aacb..8aff8a1d29bf9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/aio/_operations_mixin.py @@ -9,14 +9,9 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable -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.mgmt.core.exceptions import ARMErrorFormat +from azure.core.async_paging import AsyncItemPaged class FeatureClientOperationsMixin(object): @@ -24,12 +19,13 @@ class FeatureClientOperationsMixin(object): def list_operations( self, **kwargs: Any - ) -> AsyncItemPaged["_models.OperationListResult"]: + ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available Microsoft.Features REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('list_operations') diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py index 0180ae1129cc9..ad53d4ac63340 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['FeatureClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py index adc2767383d64..a9d30e8ddda82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(FeatureClientConfiguration, 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(FeatureClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py index 473124dd3750f..c4cbbd9e72396 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_feature_client.py @@ -6,23 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import FeatureClientConfiguration +from .operations import FeatureClientOperationsMixin, FeaturesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import FeatureClientConfiguration -from .operations import FeatureClientOperationsMixin -from .operations import FeaturesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class FeatureClient(FeatureClientOperationsMixin): """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality. @@ -33,47 +32,54 @@ class FeatureClient(FeatureClientOperationsMixin): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = FeatureClientConfiguration(credential, subscription_id, **kwargs) + self._config = FeatureClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - self.features = FeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json index d7dec292e393a..9ae9c7443fa2f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json @@ -5,13 +5,13 @@ "name": "FeatureClient", "filename": "_feature_client", "description": "Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,28 +91,27 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "features": "FeaturesOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py index 559619025efeb..8a08a800d1a0a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._feature_client import FeatureClient __all__ = ['FeatureClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py index b2c6adce0e495..5acc5e3f455f8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(FeatureClientConfiguration, 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(FeatureClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py index ca8f2939d2710..c97e161e80a49 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client.py @@ -6,22 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import FeatureClientConfiguration +from .operations import FeatureClientOperationsMixin, FeaturesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import FeatureClientConfiguration -from .operations import FeatureClientOperationsMixin -from .operations import FeaturesOperations -from .. import models - - class FeatureClient(FeatureClientOperationsMixin): """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality. @@ -31,45 +30,52 @@ class FeatureClient(FeatureClientOperationsMixin): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = FeatureClientConfiguration(credential, subscription_id, **kwargs) + self._config = FeatureClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) - self.features = FeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_feature_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_feature_client_operations.py index ddcb79c6221e2..da9a460633e56 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_feature_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_feature_client_operations.py @@ -5,22 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._feature_client_operations import build_list_operations_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FeatureClientOperationsMixin: + @distributed_trace def list_operations( self, **kwargs: Any @@ -29,7 +35,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -37,30 +44,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -78,6 +82,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_features_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_features_operations.py index f5a83a2357342..62ab882d1e507 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_features_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations/_features_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._features_operations import build_get_request, build_list_all_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, **kwargs: Any @@ -48,8 +54,10 @@ def list_all( """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -57,34 +65,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,11 +105,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore + @distributed_trace def list( self, resource_provider_namespace: str, @@ -119,8 +124,10 @@ def list( features. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -128,35 +135,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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 = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(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( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,11 +177,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -201,27 +206,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +230,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -259,27 +257,17 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,8 +281,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore + + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -317,27 +308,17 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -351,4 +332,6 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models.py index f6b6170eb2847..f15914cc251fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models.py @@ -12,10 +12,10 @@ class FeatureOperationsListResult(msrest.serialization.Model): """List of previewed features. - :param value: The array of features. - :type value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of features. + :vartype value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The array of features. + :paramtype value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(FeatureOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -35,8 +41,8 @@ def __init__( class FeatureProperties(msrest.serialization.Model): """Information about feature. - :param state: The registration state of the feature for the subscription. - :type state: str + :ivar state: The registration state of the feature for the subscription. + :vartype state: str """ _attribute_map = { @@ -47,6 +53,10 @@ def __init__( self, **kwargs ): + """ + :keyword state: The registration state of the feature for the subscription. + :paramtype state: str + """ super(FeatureProperties, self).__init__(**kwargs) self.state = kwargs.get('state', None) @@ -54,14 +64,14 @@ def __init__( class FeatureResult(msrest.serialization.Model): """Previewed feature information. - :param name: The name of the feature. - :type name: str - :param properties: Properties of the previewed feature. - :type properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties - :param id: The resource ID of the feature. - :type id: str - :param type: The resource type of the feature. - :type type: str + :ivar name: The name of the feature. + :vartype name: str + :ivar properties: Properties of the previewed feature. + :vartype properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties + :ivar id: The resource ID of the feature. + :vartype id: str + :ivar type: The resource type of the feature. + :vartype type: str """ _attribute_map = { @@ -75,6 +85,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the feature. + :paramtype name: str + :keyword properties: Properties of the previewed feature. + :paramtype properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties + :keyword id: The resource ID of the feature. + :paramtype id: str + :keyword type: The resource type of the feature. + :paramtype type: str + """ super(FeatureResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -85,10 +105,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay """ _attribute_map = { @@ -100,6 +120,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -108,12 +134,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Features. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -126,6 +152,14 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Features. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -135,10 +169,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Features operations. - :type value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Features operations. + :vartype value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -150,6 +184,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Features operations. + :paramtype value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py index f6eda01dda249..e91f7152715c1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_models_py3.py @@ -14,10 +14,10 @@ class FeatureOperationsListResult(msrest.serialization.Model): """List of previewed features. - :param value: The array of features. - :type value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of features. + :vartype value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -32,6 +32,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of features. + :paramtype value: list[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(FeatureOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -40,8 +46,8 @@ def __init__( class FeatureProperties(msrest.serialization.Model): """Information about feature. - :param state: The registration state of the feature for the subscription. - :type state: str + :ivar state: The registration state of the feature for the subscription. + :vartype state: str """ _attribute_map = { @@ -54,6 +60,10 @@ def __init__( state: Optional[str] = None, **kwargs ): + """ + :keyword state: The registration state of the feature for the subscription. + :paramtype state: str + """ super(FeatureProperties, self).__init__(**kwargs) self.state = state @@ -61,14 +71,14 @@ def __init__( class FeatureResult(msrest.serialization.Model): """Previewed feature information. - :param name: The name of the feature. - :type name: str - :param properties: Properties of the previewed feature. - :type properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties - :param id: The resource ID of the feature. - :type id: str - :param type: The resource type of the feature. - :type type: str + :ivar name: The name of the feature. + :vartype name: str + :ivar properties: Properties of the previewed feature. + :vartype properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties + :ivar id: The resource ID of the feature. + :vartype id: str + :ivar type: The resource type of the feature. + :vartype type: str """ _attribute_map = { @@ -87,6 +97,16 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the feature. + :paramtype name: str + :keyword properties: Properties of the previewed feature. + :paramtype properties: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureProperties + :keyword id: The resource ID of the feature. + :paramtype id: str + :keyword type: The resource type of the feature. + :paramtype type: str + """ super(FeatureResult, self).__init__(**kwargs) self.name = name self.properties = properties @@ -97,10 +117,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay """ _attribute_map = { @@ -115,6 +135,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -123,12 +149,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Features. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -145,6 +171,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Features. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, 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 @@ -154,10 +188,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Features operations. - :type value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Features operations. + :vartype value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -172,6 +206,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Features operations. + :paramtype value: list[~azure.mgmt.resource.features.v2015_12_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_feature_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_feature_client_operations.py index 8c19d28293e8e..be570bbfb3505 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_feature_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_feature_client_operations.py @@ -5,26 +5,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_operations_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Features/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 + ) + +# fmt: on class FeatureClientOperationsMixin(object): + @distributed_trace def list_operations( self, **kwargs # type: Any @@ -34,7 +69,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -42,30 +78,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -83,6 +116,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_features_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_features_operations.py index c87a0167a201e..ce836fde8794f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_features_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/_features_operations.py @@ -5,24 +5,206 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_all_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features') + 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 + ) + + +def build_list_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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_register_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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_unregister_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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 + ) + +# fmt: on class FeaturesOperations(object): """FeaturesOperations operations. @@ -45,6 +227,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, **kwargs # type: Any @@ -53,8 +236,10 @@ def list_all( """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -62,34 +247,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,11 +287,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore + @distributed_trace def list( self, resource_provider_namespace, # type: str @@ -125,8 +307,10 @@ def list( features. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -134,35 +318,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/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 = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(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( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,11 +360,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -208,27 +390,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +414,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -267,27 +442,17 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -301,8 +466,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore + + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -326,27 +494,17 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -360,4 +518,6 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py index 0180ae1129cc9..ad53d4ac63340 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['FeatureClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py index 72b6d25233735..3448bb67465ec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(FeatureClientConfiguration, 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(FeatureClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py index 20032bbc82ee6..95b92266130d0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_feature_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import FeatureClientConfiguration +from .operations import FeatureClientOperationsMixin, FeaturesOperations, SubscriptionFeatureRegistrationsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import FeatureClientConfiguration -from .operations import FeatureClientOperationsMixin -from .operations import FeaturesOperations -from .operations import SubscriptionFeatureRegistrationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class FeatureClient(FeatureClientOperationsMixin): """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality. @@ -31,54 +29,61 @@ class FeatureClient(FeatureClientOperationsMixin): :ivar features: FeaturesOperations operations :vartype features: azure.mgmt.resource.features.v2021_07_01.operations.FeaturesOperations :ivar subscription_feature_registrations: SubscriptionFeatureRegistrationsOperations operations - :vartype subscription_feature_registrations: azure.mgmt.resource.features.v2021_07_01.operations.SubscriptionFeatureRegistrationsOperations + :vartype subscription_feature_registrations: + azure.mgmt.resource.features.v2021_07_01.operations.SubscriptionFeatureRegistrationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = FeatureClientConfiguration(credential, subscription_id, **kwargs) + self._config = FeatureClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.features = FeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json index 5ce4e356af049..ad247de7aa677 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "FeatureClient", "filename": "_feature_client", "description": "Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"FeatureClientConfiguration\"], \"._operations_mixin\": [\"FeatureClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,29 +91,28 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "features": "FeaturesOperations", "subscription_feature_registrations": "SubscriptionFeatureRegistrationsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Features REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py index 559619025efeb..8a08a800d1a0a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._feature_client import FeatureClient __all__ = ['FeatureClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py index 61c70d9c34e5b..3f8f440b13cda 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(FeatureClientConfiguration, 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(FeatureClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py index a58df43b9ecea..8abc6db550fa3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_feature_client.py @@ -6,75 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import FeatureClientConfiguration +from .operations import FeatureClientOperationsMixin, FeaturesOperations, SubscriptionFeatureRegistrationsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import FeatureClientConfiguration -from .operations import FeatureClientOperationsMixin -from .operations import FeaturesOperations -from .operations import SubscriptionFeatureRegistrationsOperations -from .. import models - - class FeatureClient(FeatureClientOperationsMixin): """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality. :ivar features: FeaturesOperations operations :vartype features: azure.mgmt.resource.features.v2021_07_01.aio.operations.FeaturesOperations :ivar subscription_feature_registrations: SubscriptionFeatureRegistrationsOperations operations - :vartype subscription_feature_registrations: azure.mgmt.resource.features.v2021_07_01.aio.operations.SubscriptionFeatureRegistrationsOperations + :vartype subscription_feature_registrations: + azure.mgmt.resource.features.v2021_07_01.aio.operations.SubscriptionFeatureRegistrationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = FeatureClientConfiguration(credential, subscription_id, **kwargs) + self._config = FeatureClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.features = FeaturesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.features = FeaturesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_feature_registrations = SubscriptionFeatureRegistrationsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_feature_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_feature_client_operations.py index 6db129cf84bf5..ad543573d0387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_feature_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_feature_client_operations.py @@ -5,22 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._feature_client_operations import build_list_operations_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FeatureClientOperationsMixin: + @distributed_trace def list_operations( self, **kwargs: Any @@ -29,7 +35,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -37,30 +44,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -73,12 +77,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_features_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_features_operations.py index 4c8da46640563..9e181f25b3aab 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_features_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_features_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._features_operations import build_get_request, build_list_all_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, **kwargs: Any @@ -48,8 +54,10 @@ def list_all( """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -57,34 +65,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +100,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore + @distributed_trace def list( self, resource_provider_namespace: str, @@ -120,8 +125,10 @@ def list( features. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -129,35 +136,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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 = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(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( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -170,17 +173,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Features/providers/{resourceProviderNamespace}/features'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -203,33 +208,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -238,8 +233,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -262,33 +260,23 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -297,8 +285,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore + + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -321,33 +312,23 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -356,4 +337,6 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_subscription_feature_registrations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_subscription_feature_registrations_operations.py index c17e4ac34b0eb..5c384f6479ff7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_subscription_feature_registrations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/aio/operations/_subscription_feature_registrations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_feature_registrations_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_all_by_subscription_request, build_list_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, provider_namespace: str, @@ -63,33 +69,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) @@ -98,8 +94,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, provider_namespace: str, @@ -114,7 +113,8 @@ async def create_or_update( :param feature_name: The feature name. :type feature_name: str :param subscription_feature_registration_type: Subscription Feature Registration Type details. - :type subscription_feature_registration_type: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :type subscription_feature_registration_type: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionFeatureRegistration, or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration @@ -125,41 +125,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if subscription_feature_registration_type is not None: - body_content = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') + _json = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) @@ -168,8 +158,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace_async async def delete( self, provider_namespace: str, @@ -192,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -226,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, provider_namespace: str, @@ -236,8 +221,10 @@ def list_by_subscription( :param provider_namespace: The provider namespace. :type provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] + :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] @@ -245,35 +232,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - } - url = self._client.format_url(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_subscription_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + 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('SubscriptionFeatureRegistrationList', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistrationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,17 +269,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations'} # type: ignore + @distributed_trace def list_all_by_subscription( self, **kwargs: Any @@ -304,8 +289,10 @@ def list_all_by_subscription( """Returns subscription feature registrations for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] + :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] @@ -313,34 +300,29 @@ def list_all_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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_all_by_subscription.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_all_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all_by_subscription.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_all_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionFeatureRegistrationList', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistrationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -353,12 +335,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py index 1d32538b17864..c98149643ac4c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_feature_client_enums.py @@ -6,27 +6,12 @@ # 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 SubscriptionFeatureRegistrationApprovalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionFeatureRegistrationApprovalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The feature approval type. """ @@ -34,7 +19,7 @@ class SubscriptionFeatureRegistrationApprovalType(with_metaclass(_CaseInsensitiv APPROVAL_REQUIRED = "ApprovalRequired" AUTO_APPROVAL = "AutoApproval" -class SubscriptionFeatureRegistrationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionFeatureRegistrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models.py index 00c165a49d9ea..13ea85b9d325f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models.py @@ -47,6 +47,8 @@ def __init__( self, **kwargs ): + """ + """ super(AuthorizationProfile, self).__init__(**kwargs) self.requested_time = None self.requester = None @@ -64,8 +66,8 @@ class ErrorDefinition(msrest.serialization.Model): :vartype code: str :ivar message: Description of the error. :vartype message: str - :param details: Internal error details. - :type details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] """ _validation = { @@ -83,6 +85,10 @@ def __init__( self, **kwargs ): + """ + :keyword details: Internal error details. + :paramtype details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -92,8 +98,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. - :param error: The error details. - :type error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition """ _attribute_map = { @@ -104,6 +110,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -111,10 +121,10 @@ def __init__( class FeatureOperationsListResult(msrest.serialization.Model): """List of previewed features. - :param value: The array of features. - :type value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of features. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -126,6 +136,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The array of features. + :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(FeatureOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -134,8 +150,8 @@ def __init__( class FeatureProperties(msrest.serialization.Model): """Information about feature. - :param state: The registration state of the feature for the subscription. - :type state: str + :ivar state: The registration state of the feature for the subscription. + :vartype state: str """ _attribute_map = { @@ -146,6 +162,10 @@ def __init__( self, **kwargs ): + """ + :keyword state: The registration state of the feature for the subscription. + :paramtype state: str + """ super(FeatureProperties, self).__init__(**kwargs) self.state = kwargs.get('state', None) @@ -153,14 +173,14 @@ def __init__( class FeatureResult(msrest.serialization.Model): """Previewed feature information. - :param name: The name of the feature. - :type name: str - :param properties: Properties of the previewed feature. - :type properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties - :param id: The resource ID of the feature. - :type id: str - :param type: The resource type of the feature. - :type type: str + :ivar name: The name of the feature. + :vartype name: str + :ivar properties: Properties of the previewed feature. + :vartype properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties + :ivar id: The resource ID of the feature. + :vartype id: str + :ivar type: The resource type of the feature. + :vartype type: str """ _attribute_map = { @@ -174,6 +194,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the feature. + :paramtype name: str + :keyword properties: Properties of the previewed feature. + :paramtype properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties + :keyword id: The resource ID of the feature. + :paramtype id: str + :keyword type: The resource type of the feature. + :paramtype type: str + """ super(FeatureResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -184,10 +214,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay """ _attribute_map = { @@ -199,6 +229,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -207,12 +243,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Features. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -225,6 +261,14 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Features. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -234,10 +278,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Features operations. - :type value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Features operations. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -249,6 +293,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Features operations. + :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -283,6 +333,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -300,8 +352,8 @@ class SubscriptionFeatureRegistration(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param properties: - :type properties: + :ivar properties: + :vartype properties: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationProperties """ @@ -322,6 +374,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: + :paramtype properties: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationProperties + """ super(SubscriptionFeatureRegistration, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) @@ -329,11 +386,10 @@ def __init__( class SubscriptionFeatureRegistrationList(msrest.serialization.Model): """The list of subscription feature registrations. - :param next_link: The link used to get the next page of subscription feature registrations - list. - :type next_link: str - :param value: The list of subscription feature registrations. - :type value: + :ivar next_link: The link used to get the next page of subscription feature registrations list. + :vartype next_link: str + :ivar value: The list of subscription feature registrations. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] """ @@ -346,6 +402,14 @@ def __init__( self, **kwargs ): + """ + :keyword next_link: The link used to get the next page of subscription feature registrations + list. + :paramtype next_link: str + :keyword value: The list of subscription feature registrations. + :paramtype value: + list[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + """ super(SubscriptionFeatureRegistrationList, self).__init__(**kwargs) self.next_link = kwargs.get('next_link', None) self.value = kwargs.get('value', None) @@ -366,15 +430,15 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): :vartype display_name: str :ivar provider_namespace: The providerNamespace. :vartype provider_namespace: str - :param state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", + :ivar state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", "Registering", "Registered", "Unregistering", "Unregistered". - :type state: str or + :vartype state: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState - :param authorization_profile: Authorization Profile. - :type authorization_profile: + :ivar authorization_profile: Authorization Profile. + :vartype authorization_profile: ~azure.mgmt.resource.features.v2021_07_01.models.AuthorizationProfile - :param metadata: Key-value pairs for meta data. - :type metadata: dict[str, str] + :ivar metadata: Key-value pairs for meta data. + :vartype metadata: dict[str, str] :ivar release_date: The feature release date. :vartype release_date: ~datetime.datetime :ivar registration_date: The feature registration date. @@ -385,11 +449,11 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): "ApprovalRequired", "AutoApproval". :vartype approval_type: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationApprovalType - :param should_feature_display_in_portal: Indicates whether feature should be displayed in + :ivar should_feature_display_in_portal: Indicates whether feature should be displayed in Portal. - :type should_feature_display_in_portal: bool - :param description: The feature description. - :type description: str + :vartype should_feature_display_in_portal: bool + :ivar description: The feature description. + :vartype description: str """ _validation = { @@ -426,6 +490,22 @@ def __init__( self, **kwargs ): + """ + :keyword state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", + "Registering", "Registered", "Unregistering", "Unregistered". + :paramtype state: str or + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState + :keyword authorization_profile: Authorization Profile. + :paramtype authorization_profile: + ~azure.mgmt.resource.features.v2021_07_01.models.AuthorizationProfile + :keyword metadata: Key-value pairs for meta data. + :paramtype metadata: dict[str, str] + :keyword should_feature_display_in_portal: Indicates whether feature should be displayed in + Portal. + :paramtype should_feature_display_in_portal: bool + :keyword description: The feature description. + :paramtype description: str + """ super(SubscriptionFeatureRegistrationProperties, self).__init__(**kwargs) self.tenant_id = None self.subscription_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py index 6a96a6da0f604..6530648cef2b1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/models/_models_py3.py @@ -51,6 +51,8 @@ def __init__( self, **kwargs ): + """ + """ super(AuthorizationProfile, self).__init__(**kwargs) self.requested_time = None self.requester = None @@ -68,8 +70,8 @@ class ErrorDefinition(msrest.serialization.Model): :vartype code: str :ivar message: Description of the error. :vartype message: str - :param details: Internal error details. - :type details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] """ _validation = { @@ -89,6 +91,10 @@ def __init__( details: Optional[List["ErrorDefinition"]] = None, **kwargs ): + """ + :keyword details: Internal error details. + :paramtype details: list[~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition] + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -98,8 +104,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. - :param error: The error details. - :type error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition """ _attribute_map = { @@ -112,6 +118,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.features.v2021_07_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -119,10 +129,10 @@ def __init__( class FeatureOperationsListResult(msrest.serialization.Model): """List of previewed features. - :param value: The array of features. - :type value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of features. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -137,6 +147,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of features. + :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.FeatureResult] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(FeatureOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -145,8 +161,8 @@ def __init__( class FeatureProperties(msrest.serialization.Model): """Information about feature. - :param state: The registration state of the feature for the subscription. - :type state: str + :ivar state: The registration state of the feature for the subscription. + :vartype state: str """ _attribute_map = { @@ -159,6 +175,10 @@ def __init__( state: Optional[str] = None, **kwargs ): + """ + :keyword state: The registration state of the feature for the subscription. + :paramtype state: str + """ super(FeatureProperties, self).__init__(**kwargs) self.state = state @@ -166,14 +186,14 @@ def __init__( class FeatureResult(msrest.serialization.Model): """Previewed feature information. - :param name: The name of the feature. - :type name: str - :param properties: Properties of the previewed feature. - :type properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties - :param id: The resource ID of the feature. - :type id: str - :param type: The resource type of the feature. - :type type: str + :ivar name: The name of the feature. + :vartype name: str + :ivar properties: Properties of the previewed feature. + :vartype properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties + :ivar id: The resource ID of the feature. + :vartype id: str + :ivar type: The resource type of the feature. + :vartype type: str """ _attribute_map = { @@ -192,6 +212,16 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the feature. + :paramtype name: str + :keyword properties: Properties of the previewed feature. + :paramtype properties: ~azure.mgmt.resource.features.v2021_07_01.models.FeatureProperties + :keyword id: The resource ID of the feature. + :paramtype id: str + :keyword type: The resource type of the feature. + :paramtype type: str + """ super(FeatureResult, self).__init__(**kwargs) self.name = name self.properties = properties @@ -202,10 +232,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay """ _attribute_map = { @@ -220,6 +250,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.features.v2021_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -228,12 +264,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Features. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -250,6 +286,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Features. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, 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 @@ -259,10 +303,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Features operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Features operations. - :type value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Features operations. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -277,6 +321,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Features operations. + :paramtype value: list[~azure.mgmt.resource.features.v2021_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -311,6 +361,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -328,8 +380,8 @@ class SubscriptionFeatureRegistration(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param properties: - :type properties: + :ivar properties: + :vartype properties: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationProperties """ @@ -352,6 +404,11 @@ def __init__( properties: Optional["SubscriptionFeatureRegistrationProperties"] = None, **kwargs ): + """ + :keyword properties: + :paramtype properties: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationProperties + """ super(SubscriptionFeatureRegistration, self).__init__(**kwargs) self.properties = properties @@ -359,11 +416,10 @@ def __init__( class SubscriptionFeatureRegistrationList(msrest.serialization.Model): """The list of subscription feature registrations. - :param next_link: The link used to get the next page of subscription feature registrations - list. - :type next_link: str - :param value: The list of subscription feature registrations. - :type value: + :ivar next_link: The link used to get the next page of subscription feature registrations list. + :vartype next_link: str + :ivar value: The list of subscription feature registrations. + :vartype value: list[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] """ @@ -379,6 +435,14 @@ def __init__( value: Optional[List["SubscriptionFeatureRegistration"]] = None, **kwargs ): + """ + :keyword next_link: The link used to get the next page of subscription feature registrations + list. + :paramtype next_link: str + :keyword value: The list of subscription feature registrations. + :paramtype value: + list[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration] + """ super(SubscriptionFeatureRegistrationList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -399,15 +463,15 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): :vartype display_name: str :ivar provider_namespace: The providerNamespace. :vartype provider_namespace: str - :param state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", + :ivar state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", "Registering", "Registered", "Unregistering", "Unregistered". - :type state: str or + :vartype state: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState - :param authorization_profile: Authorization Profile. - :type authorization_profile: + :ivar authorization_profile: Authorization Profile. + :vartype authorization_profile: ~azure.mgmt.resource.features.v2021_07_01.models.AuthorizationProfile - :param metadata: Key-value pairs for meta data. - :type metadata: dict[str, str] + :ivar metadata: Key-value pairs for meta data. + :vartype metadata: dict[str, str] :ivar release_date: The feature release date. :vartype release_date: ~datetime.datetime :ivar registration_date: The feature registration date. @@ -418,11 +482,11 @@ class SubscriptionFeatureRegistrationProperties(msrest.serialization.Model): "ApprovalRequired", "AutoApproval". :vartype approval_type: str or ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationApprovalType - :param should_feature_display_in_portal: Indicates whether feature should be displayed in + :ivar should_feature_display_in_portal: Indicates whether feature should be displayed in Portal. - :type should_feature_display_in_portal: bool - :param description: The feature description. - :type description: str + :vartype should_feature_display_in_portal: bool + :ivar description: The feature description. + :vartype description: str """ _validation = { @@ -465,6 +529,22 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword state: The state. Possible values include: "NotSpecified", "NotRegistered", "Pending", + "Registering", "Registered", "Unregistering", "Unregistered". + :paramtype state: str or + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationState + :keyword authorization_profile: Authorization Profile. + :paramtype authorization_profile: + ~azure.mgmt.resource.features.v2021_07_01.models.AuthorizationProfile + :keyword metadata: Key-value pairs for meta data. + :paramtype metadata: dict[str, str] + :keyword should_feature_display_in_portal: Indicates whether feature should be displayed in + Portal. + :paramtype should_feature_display_in_portal: bool + :keyword description: The feature description. + :paramtype description: str + """ super(SubscriptionFeatureRegistrationProperties, self).__init__(**kwargs) self.tenant_id = None self.subscription_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_feature_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_feature_client_operations.py index 717bd091eb2d4..5b2f7f6955c9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_feature_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_feature_client_operations.py @@ -5,26 +5,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_operations_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Features/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 + ) + +# fmt: on class FeatureClientOperationsMixin(object): + @distributed_trace def list_operations( self, **kwargs # type: Any @@ -34,7 +69,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -42,30 +78,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -78,12 +111,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_features_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_features_operations.py index 8a5acdc4a958e..fd26596d91c61 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_features_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_features_operations.py @@ -5,24 +5,206 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_all_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features') + 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 + ) + + +def build_list_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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_register_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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_unregister_request( + resource_provider_namespace, # type: str + feature_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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 + ) + +# fmt: on class FeaturesOperations(object): """FeaturesOperations operations. @@ -45,6 +227,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, **kwargs # type: Any @@ -53,8 +236,10 @@ def list_all( """Gets all the preview features that are available through AFEC for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -62,34 +247,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.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_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +282,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore + @distributed_trace def list( self, resource_provider_namespace, # type: str @@ -126,8 +308,10 @@ def list( features. :type resource_provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FeatureOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] + :return: An iterator like instance of either FeatureOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.FeatureOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.FeatureOperationsListResult"] @@ -135,35 +319,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/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 = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(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( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + deserialized = self._deserialize("FeatureOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -176,17 +356,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Features/providers/{resourceProviderNamespace}/features'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -210,33 +392,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -245,8 +417,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -270,33 +445,23 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -305,8 +470,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore + + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -330,33 +498,23 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json, text/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + feature_name=feature_name, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('FeatureResult', pipeline_response) @@ -365,4 +523,6 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_subscription_feature_registrations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_subscription_feature_registrations_operations.py index 99e262630b1d3..e458cc71f174b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_subscription_feature_registrations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2021_07_01/operations/_subscription_feature_registrations_operations.py @@ -5,24 +5,210 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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, # type: str + provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), + "featureName": _SERIALIZER.url("feature_name", feature_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_subscription_request( + subscription_id, # type: str + provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_all_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations') + 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 + ) + +# fmt: on class SubscriptionFeatureRegistrationsOperations(object): """SubscriptionFeatureRegistrationsOperations operations. @@ -45,6 +231,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, provider_namespace, # type: str @@ -68,33 +255,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) @@ -103,8 +280,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace def create_or_update( self, provider_namespace, # type: str @@ -120,7 +300,8 @@ def create_or_update( :param feature_name: The feature name. :type feature_name: str :param subscription_feature_registration_type: Subscription Feature Registration Type details. - :type subscription_feature_registration_type: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration + :type subscription_feature_registration_type: + ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionFeatureRegistration, or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistration @@ -131,41 +312,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if subscription_feature_registration_type is not None: - body_content = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') + _json = self._serialize.body(subscription_feature_registration_type, 'SubscriptionFeatureRegistration') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionFeatureRegistration', pipeline_response) @@ -174,8 +345,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace def delete( self, provider_namespace, # type: str @@ -199,33 +373,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - 'featureName': self._serialize.url("feature_name", feature_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + feature_name=feature_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -233,6 +397,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, provider_namespace, # type: str @@ -244,8 +410,10 @@ def list_by_subscription( :param provider_namespace: The provider namespace. :type provider_namespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] + :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] @@ -253,35 +421,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'providerNamespace': self._serialize.url("provider_namespace", provider_namespace, 'str'), - } - url = self._client.format_url(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_subscription_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + provider_namespace=provider_namespace, + 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('SubscriptionFeatureRegistrationList', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistrationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,17 +458,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations'} # type: ignore + @distributed_trace def list_all_by_subscription( self, **kwargs # type: Any @@ -313,8 +479,10 @@ def list_all_by_subscription( """Returns subscription feature registrations for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] + :return: An iterator like instance of either SubscriptionFeatureRegistrationList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.features.v2021_07_01.models.SubscriptionFeatureRegistrationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionFeatureRegistrationList"] @@ -322,34 +490,29 @@ def list_all_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-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_all_by_subscription.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_all_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all_by_subscription.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_all_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionFeatureRegistrationList', pipeline_response) + deserialized = self._deserialize("SubscriptionFeatureRegistrationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -362,12 +525,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py index 9d1d758e5405a..8ee473bb1ccf8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py index 4f6e4acd8e7dc..3c035d08a5cd2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/_management_link_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -69,12 +68,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = ManagementLinkClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ManagementLinkClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py index 67aba20ed5762..3edb5cf1cc609 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py index e3503bb79b5d1..30f53e0c0a384 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/aio/_management_link_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -67,12 +67,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = ManagementLinkClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ManagementLinkClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py index eb096a690287b..70d7514c712f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ManagementLinkClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py index e16cbf69220f0..89a2d0a0990fa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ManagementLinkClientConfiguration, 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(ManagementLinkClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py index 370083b87d497..b2a30ac0bfe55 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_management_link_client.py @@ -6,23 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ManagementLinkClientConfiguration +from .operations import Operations, ResourceLinksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ManagementLinkClientConfiguration -from .operations import Operations -from .operations import ResourceLinksOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ManagementLinkClient(object): """Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any of the linked resources are deleted or moved, the link owner must clean up the remaining link. @@ -30,54 +29,61 @@ class ManagementLinkClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.links.v2016_09_01.operations.Operations :ivar resource_links: ResourceLinksOperations operations - :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.operations.ResourceLinksOperations + :vartype resource_links: + azure.mgmt.resource.links.v2016_09_01.operations.ResourceLinksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagementLinkClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLinkClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_links = ResourceLinksOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_links = ResourceLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json index de046d983b4d7..6ce2b2d418092 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ManagementLinkClient", "filename": "_management_link_client", "description": "Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any of the linked resources are deleted or moved, the link owner must clean up the remaining link.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLinkClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py index cfc4823623437..ea7512a1012fe 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._management_link_client import ManagementLinkClient __all__ = ['ManagementLinkClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py index f522fb30a33f4..ae37bc2a01257 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ManagementLinkClientConfiguration, 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(ManagementLinkClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py index 37a7dfd6ce536..90e463168e64e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client.py @@ -6,74 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ManagementLinkClientConfiguration +from .operations import Operations, ResourceLinksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ManagementLinkClientConfiguration -from .operations import Operations -from .operations import ResourceLinksOperations -from .. import models - - -class ManagementLinkClient(object): +class ManagementLinkClient: """Azure resources can be linked together to form logical relationships. You can establish links between resources belonging to different resource groups. However, all the linked resources must belong to the same subscription. Each resource can be linked to 50 other resources. If any of the linked resources are deleted or moved, the link owner must clean up the remaining link. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.links.v2016_09_01.aio.operations.Operations :ivar resource_links: ResourceLinksOperations operations - :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.aio.operations.ResourceLinksOperations + :vartype resource_links: + azure.mgmt.resource.links.v2016_09_01.aio.operations.ResourceLinksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = ManagementLinkClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLinkClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_links = ResourceLinksOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_links = ResourceLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py index 1b9a6d0f78a17..c435e340ba503 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.links.v2016_09_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_resource_links_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_resource_links_operations.py index 755c09877c05d..b4bc016a0c940 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_resource_links_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations/_resource_links_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_links_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_at_source_scope_request, build_list_at_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, link_id: str, @@ -63,23 +69,15 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + link_id=link_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,6 +90,8 @@ async def delete( delete.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, link_id: str, @@ -117,30 +117,20 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceLink') + + request = build_create_or_update_request( + link_id=link_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceLink') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,8 +148,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace_async async def get( self, link_id: str, @@ -180,25 +173,15 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + link_id=link_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -212,8 +195,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace def list_at_subscription( self, filter: Optional[str] = None, @@ -226,7 +212,8 @@ def list_at_subscription( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] @@ -234,36 +221,31 @@ def list_at_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_subscription.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] - 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_at_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription.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_at_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + deserialized = self._deserialize("ResourceLinkResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -281,11 +263,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links'} # type: ignore + @distributed_trace def list_at_source_scope( self, scope: str, @@ -299,11 +283,12 @@ def list_at_source_scope( /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. :type scope: str :param filter: The filter to apply when getting resource links. To get links only at the - specified scope (not below the scope), use Filter.atScope(). + specified scope (not below the scope), use Filter.atScope(). The default value is "atScope()". :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] @@ -311,36 +296,31 @@ def list_at_source_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_source_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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_at_source_scope_request( + scope=scope, + filter=filter, + template_url=self.list_at_source_scope.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_at_source_scope_request( + scope=scope, + 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('ResourceLinkResult', pipeline_response) + deserialized = self._deserialize("ResourceLinkResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,6 +338,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models.py index 30c649dc63ff5..9d693e4b0583b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models.py @@ -12,10 +12,10 @@ class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -35,14 +41,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -56,6 +62,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -66,10 +82,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -81,6 +97,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -97,8 +119,8 @@ class ResourceLink(msrest.serialization.Model): :vartype name: str :ivar type: The resource link object. :vartype type: any - :param properties: Properties for resource link. - :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :ivar properties: Properties for resource link. + :vartype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ _validation = { @@ -118,6 +140,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Properties for resource link. + :paramtype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + """ super(ResourceLink, self).__init__(**kwargs) self.id = None self.name = None @@ -130,8 +156,8 @@ class ResourceLinkFilter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_id: Required. The ID of the target resource. - :type target_id: str + :ivar target_id: Required. The ID of the target resource. + :vartype target_id: str """ _validation = { @@ -146,6 +172,10 @@ def __init__( self, **kwargs ): + """ + :keyword target_id: Required. The ID of the target resource. + :paramtype target_id: str + """ super(ResourceLinkFilter, self).__init__(**kwargs) self.target_id = kwargs['target_id'] @@ -159,10 +189,10 @@ class ResourceLinkProperties(msrest.serialization.Model): :ivar source_id: The fully qualified ID of the source resource in the link. :vartype source_id: str - :param target_id: Required. The fully qualified ID of the target resource in the link. - :type target_id: str - :param notes: Notes about the resource link. - :type notes: str + :ivar target_id: Required. The fully qualified ID of the target resource in the link. + :vartype target_id: str + :ivar notes: Notes about the resource link. + :vartype notes: str """ _validation = { @@ -180,6 +210,12 @@ def __init__( self, **kwargs ): + """ + :keyword target_id: Required. The fully qualified ID of the target resource in the link. + :paramtype target_id: str + :keyword notes: Notes about the resource link. + :paramtype notes: str + """ super(ResourceLinkProperties, self).__init__(**kwargs) self.source_id = None self.target_id = kwargs['target_id'] @@ -193,8 +229,8 @@ class ResourceLinkResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. An array of resource links. - :type value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :ivar value: Required. An array of resource links. + :vartype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -213,6 +249,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. An array of resource links. + :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + """ super(ResourceLinkResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py index 30ed79eafad85..ffc3cac3e583f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_models_py3.py @@ -14,10 +14,10 @@ class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -32,6 +32,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -40,14 +46,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -66,6 +72,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -76,10 +92,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -94,6 +110,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -110,8 +132,8 @@ class ResourceLink(msrest.serialization.Model): :vartype name: str :ivar type: The resource link object. :vartype type: any - :param properties: Properties for resource link. - :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :ivar properties: Properties for resource link. + :vartype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ _validation = { @@ -133,6 +155,10 @@ def __init__( properties: Optional["ResourceLinkProperties"] = None, **kwargs ): + """ + :keyword properties: Properties for resource link. + :paramtype properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + """ super(ResourceLink, self).__init__(**kwargs) self.id = None self.name = None @@ -145,8 +171,8 @@ class ResourceLinkFilter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_id: Required. The ID of the target resource. - :type target_id: str + :ivar target_id: Required. The ID of the target resource. + :vartype target_id: str """ _validation = { @@ -163,6 +189,10 @@ def __init__( target_id: str, **kwargs ): + """ + :keyword target_id: Required. The ID of the target resource. + :paramtype target_id: str + """ super(ResourceLinkFilter, self).__init__(**kwargs) self.target_id = target_id @@ -176,10 +206,10 @@ class ResourceLinkProperties(msrest.serialization.Model): :ivar source_id: The fully qualified ID of the source resource in the link. :vartype source_id: str - :param target_id: Required. The fully qualified ID of the target resource in the link. - :type target_id: str - :param notes: Notes about the resource link. - :type notes: str + :ivar target_id: Required. The fully qualified ID of the target resource in the link. + :vartype target_id: str + :ivar notes: Notes about the resource link. + :vartype notes: str """ _validation = { @@ -200,6 +230,12 @@ def __init__( notes: Optional[str] = None, **kwargs ): + """ + :keyword target_id: Required. The fully qualified ID of the target resource in the link. + :paramtype target_id: str + :keyword notes: Notes about the resource link. + :paramtype notes: str + """ super(ResourceLinkProperties, self).__init__(**kwargs) self.source_id = None self.target_id = target_id @@ -213,8 +249,8 @@ class ResourceLinkResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. An array of resource links. - :type value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + :ivar value: Required. An array of resource links. + :vartype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -235,6 +271,10 @@ def __init__( value: List["ResourceLink"], **kwargs ): + """ + :keyword value: Required. An array of resource links. + :paramtype value: list[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] + """ super(ResourceLinkResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py index f75bcabcd8fcf..0ed6b50032f94 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.links.v2016_09_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_resource_links_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_resource_links_operations.py index 3f32413b34d1f..9764f49bbfcbc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_resource_links_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/_resource_links_operations.py @@ -5,24 +5,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + link_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/{linkId}') + path_format_arguments = { + "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + link_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{linkId}') + path_format_arguments = { + "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + link_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{linkId}') + path_format_arguments = { + "linkId": _SERIALIZER.url("link_id", link_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links') + 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] + 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_list_at_source_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', "atScope()") # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/links') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class ResourceLinksOperations(object): """ResourceLinksOperations operations. @@ -45,6 +219,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, link_id, # type: str @@ -68,23 +243,15 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + link_id=link_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,6 +264,8 @@ def delete( delete.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace def create_or_update( self, link_id, # type: str @@ -123,30 +292,20 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceLink') + + request = build_create_or_update_request( + link_id=link_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceLink') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +323,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace def get( self, link_id, # type: str @@ -187,25 +349,15 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + link_id=link_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -219,8 +371,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{linkId}'} # type: ignore + + @distributed_trace def list_at_subscription( self, filter=None, # type: Optional[str] @@ -234,7 +389,8 @@ def list_at_subscription( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] @@ -242,36 +398,31 @@ def list_at_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_subscription.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] - 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_at_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription.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_at_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + deserialized = self._deserialize("ResourceLinkResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -289,11 +440,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links'} # type: ignore + @distributed_trace def list_at_source_scope( self, scope, # type: str @@ -308,11 +461,12 @@ def list_at_source_scope( /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. :type scope: str :param filter: The filter to apply when getting resource links. To get links only at the - specified scope (not below the scope), use Filter.atScope(). + specified scope (not below the scope), use Filter.atScope(). The default value is "atScope()". :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceLinkResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceLinkResult"] @@ -320,36 +474,31 @@ def list_at_source_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_source_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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_at_source_scope_request( + scope=scope, + filter=filter, + template_url=self.list_at_source_scope.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_at_source_scope_request( + scope=scope, + 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('ResourceLinkResult', pipeline_response) + deserialized = self._deserialize("ResourceLinkResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -367,6 +516,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py index 9042a6ab1a343..39cfe1f7a778d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py index 37f2ee6d7e0c3..fcbee483a1f52 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/_management_lock_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -69,12 +68,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ManagementLockClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py index 0f21239c3f583..f1668af3249a5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py index d4753de3c3c91..664d77f0de39f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/aio/_management_lock_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -67,12 +67,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ManagementLockClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py index 64929888def77..94979e384920d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ManagementLockClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py index 38835f3f1bbb5..f8305d8085725 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ManagementLockClientConfiguration, 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(ManagementLockClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py index e2740fd976e0c..68d7b1101c27c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_management_lock_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ManagementLockClientConfiguration +from .operations import ManagementLocksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ManagementLockClientConfiguration -from .operations import ManagementLocksOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ManagementLockClient(object): """ManagementLockClient. :ivar management_locks: ManagementLocksOperations operations - :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.operations.ManagementLocksOperations + :vartype management_locks: + azure.mgmt.resource.locks.v2015_01_01.operations.ManagementLocksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json index 5490874f4a53f..fc08d12859914 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ManagementLockClient", "filename": "_management_lock_client", "description": "ManagementLockClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "management_locks": "ManagementLocksOperations" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py index c6025457e1d14..b16e12de5ea7f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._management_lock_client import ManagementLockClient __all__ = ['ManagementLockClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py index d2e1c21cb0c6a..b1d70db4f1c75 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ManagementLockClientConfiguration, 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(ManagementLockClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py index af7f5a6ad0278..e07a56bd21aec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client.py @@ -6,69 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest 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 .. import models from ._configuration import ManagementLockClientConfiguration from .operations import ManagementLocksOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ManagementLockClient(object): +class ManagementLockClient: """ManagementLockClient. :ivar management_locks: ManagementLocksOperations operations - :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.aio.operations.ManagementLocksOperations + :vartype management_locks: + azure.mgmt.resource.locks.v2015_01_01.aio.operations.ManagementLocksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_management_locks_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_management_locks_operations.py index 7c76b1233eb3b..2f8fb3e29ba92 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_management_locks_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations/_management_locks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._management_locks_operations import build_create_or_update_at_resource_group_level_request, build_create_or_update_at_resource_level_request, build_create_or_update_at_subscription_level_request, build_delete_at_resource_group_level_request, build_delete_at_resource_level_request, build_delete_at_subscription_level_request, build_get_at_resource_group_level_request, build_get_request, build_list_at_resource_group_level_request, build_list_at_resource_level_request, build_list_at_subscription_level_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update_at_resource_group_level( self, resource_group_name: str, @@ -66,32 +72,22 @@ async def create_or_update_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +105,11 @@ async def create_or_update_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_resource_group_level( self, resource_group_name: str, @@ -133,25 +132,17 @@ async def delete_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - - # Construct URL - url = self.delete_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,6 +155,8 @@ async def delete_at_resource_group_level( delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get_at_resource_group_level( self, resource_group_name: str, @@ -186,27 +179,17 @@ async def get_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -220,8 +203,11 @@ async def get_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_resource_level( self, resource_group_name: str, @@ -259,36 +245,26 @@ async def create_or_update_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,8 +282,11 @@ async def create_or_update_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_resource_level( self, resource_group_name: str, @@ -342,29 +321,21 @@ async def delete_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - - # Construct URL - url = self.delete_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -377,6 +348,8 @@ async def delete_at_resource_level( delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_subscription_level( self, lock_name: str, @@ -399,31 +372,21 @@ async def create_or_update_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -441,8 +404,11 @@ async def create_or_update_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_subscription_level( self, lock_name: str, @@ -462,24 +428,16 @@ async def delete_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - # Construct URL - url = self.delete_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -492,6 +450,8 @@ async def delete_at_subscription_level( delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get( self, lock_name: str, @@ -511,26 +471,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -544,8 +494,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def list_at_resource_group_level( self, resource_group_name: str, @@ -559,8 +512,10 @@ def list_at_resource_group_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -568,37 +523,33 @@ def list_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_resource_group_level.metadata['url'] # type: 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] - 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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_group_level.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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -616,11 +567,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_resource_level( self, resource_group_name: str, @@ -646,8 +599,10 @@ def list_at_resource_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -655,41 +610,41 @@ def list_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_level.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -707,11 +662,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_subscription_level( self, filter: Optional[str] = None, @@ -722,8 +679,10 @@ def list_at_subscription_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -731,36 +690,31 @@ def list_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_subscription_level.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] - 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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription_level.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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -778,6 +732,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py index c118fa6f78381..b9f3d543402ab 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_management_lock_client_enums.py @@ -6,27 +6,12 @@ # 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 LockLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The lock level of the management lock. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models.py index 4c621de1cf85b..b930f2c95735e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models.py @@ -12,10 +12,10 @@ class ManagementLockListResult(msrest.serialization.Model): """List of management locks. - :param value: The list of locks. - :type value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of locks. + :vartype value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of locks. + :paramtype value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(ManagementLockListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -41,13 +47,13 @@ class ManagementLockObject(msrest.serialization.Model): :vartype id: str :ivar type: The type of the lock. :vartype type: str - :param name: The name of the lock. - :type name: str - :param level: The lock level of the management lock. Possible values include: "NotSpecified", + :ivar name: The name of the lock. + :vartype name: str + :ivar level: The lock level of the management lock. Possible values include: "NotSpecified", "CanNotDelete", "ReadOnly". - :type level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel - :param notes: The notes of the management lock. - :type notes: str + :vartype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel + :ivar notes: The notes of the management lock. + :vartype notes: str """ _validation = { @@ -67,6 +73,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the lock. + :paramtype name: str + :keyword level: The lock level of the management lock. Possible values include: "NotSpecified", + "CanNotDelete", "ReadOnly". + :paramtype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel + :keyword notes: The notes of the management lock. + :paramtype notes: str + """ super(ManagementLockObject, self).__init__(**kwargs) self.id = None self.type = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py index 08cb43d077162..8c1bf60deab95 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_models_py3.py @@ -16,10 +16,10 @@ class ManagementLockListResult(msrest.serialization.Model): """List of management locks. - :param value: The list of locks. - :type value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of locks. + :vartype value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of locks. + :paramtype value: list[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(ManagementLockListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -48,13 +54,13 @@ class ManagementLockObject(msrest.serialization.Model): :vartype id: str :ivar type: The type of the lock. :vartype type: str - :param name: The name of the lock. - :type name: str - :param level: The lock level of the management lock. Possible values include: "NotSpecified", + :ivar name: The name of the lock. + :vartype name: str + :ivar level: The lock level of the management lock. Possible values include: "NotSpecified", "CanNotDelete", "ReadOnly". - :type level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel - :param notes: The notes of the management lock. - :type notes: str + :vartype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel + :ivar notes: The notes of the management lock. + :vartype notes: str """ _validation = { @@ -78,6 +84,15 @@ def __init__( notes: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the lock. + :paramtype name: str + :keyword level: The lock level of the management lock. Possible values include: "NotSpecified", + "CanNotDelete", "ReadOnly". + :paramtype level: str or ~azure.mgmt.resource.locks.v2015_01_01.models.LockLevel + :keyword notes: The notes of the management lock. + :paramtype notes: str + """ super(ManagementLockObject, self).__init__(**kwargs) self.id = None self.type = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_management_locks_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_management_locks_operations.py index aad1b98589d77..5f262971882ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_management_locks_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/_management_locks_operations.py @@ -5,24 +5,444 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-01-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-01-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_level_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_subscription_level_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-01-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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_at_resource_group_level_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks') + 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] + 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_list_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_at_subscription_level_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks') + 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] + 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 + ) + +# fmt: on class ManagementLocksOperations(object): """ManagementLocksOperations operations. @@ -45,6 +465,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update_at_resource_group_level( self, resource_group_name, # type: str @@ -71,32 +492,22 @@ def create_or_update_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -114,8 +525,11 @@ def create_or_update_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_resource_group_level( self, resource_group_name, # type: str @@ -139,25 +553,17 @@ def delete_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - - # Construct URL - url = self.delete_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,6 +576,8 @@ def delete_at_resource_group_level( delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get_at_resource_group_level( self, resource_group_name, # type: str @@ -193,27 +601,17 @@ def get_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -227,8 +625,11 @@ def get_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def create_or_update_at_resource_level( self, resource_group_name, # type: str @@ -267,36 +668,26 @@ def create_or_update_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -314,8 +705,11 @@ def create_or_update_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_resource_level( self, resource_group_name, # type: str @@ -351,29 +745,21 @@ def delete_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - - # Construct URL - url = self.delete_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,6 +772,8 @@ def delete_at_resource_level( delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def create_or_update_at_subscription_level( self, lock_name, # type: str @@ -409,31 +797,21 @@ def create_or_update_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -451,8 +829,11 @@ def create_or_update_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_subscription_level( self, lock_name, # type: str @@ -473,24 +854,16 @@ def delete_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - # Construct URL - url = self.delete_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -503,6 +876,8 @@ def delete_at_subscription_level( delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get( self, lock_name, # type: str @@ -523,26 +898,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -556,8 +921,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def list_at_resource_group_level( self, resource_group_name, # type: str @@ -572,8 +940,10 @@ def list_at_resource_group_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -581,37 +951,33 @@ def list_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_resource_group_level.metadata['url'] # type: 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] - 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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_group_level.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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,11 +995,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_resource_level( self, resource_group_name, # type: str @@ -660,8 +1028,10 @@ def list_at_resource_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -669,41 +1039,41 @@ def list_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_level.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -721,11 +1091,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_subscription_level( self, filter=None, # type: Optional[str] @@ -737,8 +1109,10 @@ def list_at_subscription_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -746,36 +1120,31 @@ def list_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-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_at_subscription_level.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] - 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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription_level.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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -793,6 +1162,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py index 64929888def77..94979e384920d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ManagementLockClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py index a371145a4606c..58718a417423b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ManagementLockClientConfiguration, 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(ManagementLockClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py index 9ff644d882678..1223dd7e76915 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_management_lock_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ManagementLockClientConfiguration +from .operations import AuthorizationOperationsOperations, ManagementLocksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ManagementLockClientConfiguration -from .operations import AuthorizationOperationsOperations -from .operations import ManagementLocksOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ManagementLockClient(object): """Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. :ivar authorization_operations: AuthorizationOperationsOperations operations - :vartype authorization_operations: azure.mgmt.resource.locks.v2016_09_01.operations.AuthorizationOperationsOperations + :vartype authorization_operations: + azure.mgmt.resource.locks.v2016_09_01.operations.AuthorizationOperationsOperations :ivar management_locks: ManagementLocksOperations operations - :vartype management_locks: azure.mgmt.resource.locks.v2016_09_01.operations.ManagementLocksOperations + :vartype management_locks: + azure.mgmt.resource.locks.v2016_09_01.operations.ManagementLocksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.authorization_operations = AuthorizationOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_operations = AuthorizationOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json index fe8f3f56f9751..607d39683d9ab 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ManagementLockClient", "filename": "_management_lock_client", "description": "Azure resources can be locked to prevent other users in your organization from deleting or modifying resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementLockClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "authorization_operations": "AuthorizationOperationsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py index c6025457e1d14..b16e12de5ea7f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._management_lock_client import ManagementLockClient __all__ = ['ManagementLockClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py index 3a1777ce5f2af..64f33c742eb00 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ManagementLockClientConfiguration, 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(ManagementLockClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py index 5783b49d8b807..035c976aefac5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ManagementLockClientConfiguration +from .operations import AuthorizationOperationsOperations, ManagementLocksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ManagementLockClientConfiguration -from .operations import AuthorizationOperationsOperations -from .operations import ManagementLocksOperations -from .. import models - - -class ManagementLockClient(object): +class ManagementLockClient: """Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. :ivar authorization_operations: AuthorizationOperationsOperations operations - :vartype authorization_operations: azure.mgmt.resource.locks.v2016_09_01.aio.operations.AuthorizationOperationsOperations + :vartype authorization_operations: + azure.mgmt.resource.locks.v2016_09_01.aio.operations.AuthorizationOperationsOperations :ivar management_locks: ManagementLocksOperations operations - :vartype management_locks: azure.mgmt.resource.locks.v2016_09_01.aio.operations.ManagementLocksOperations + :vartype management_locks: + azure.mgmt.resource.locks.v2016_09_01.aio.operations.ManagementLocksOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = ManagementLockClientConfiguration(credential, subscription_id, **kwargs) + self._config = ManagementLockClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.authorization_operations = AuthorizationOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_locks = ManagementLocksOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_operations = AuthorizationOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_locks = ManagementLocksOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_authorization_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_authorization_operations_operations.py index 053cbcd3ce196..09d430b99c827 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_authorization_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_authorization_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._authorization_operations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.locks.v2016_09_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_management_locks_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_management_locks_operations.py index 62139d55fa390..2df47e360b963 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_management_locks_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations/_management_locks_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._management_locks_operations import build_create_or_update_at_resource_group_level_request, build_create_or_update_at_resource_level_request, build_create_or_update_at_subscription_level_request, build_create_or_update_by_scope_request, build_delete_at_resource_group_level_request, build_delete_at_resource_level_request, build_delete_at_subscription_level_request, build_delete_by_scope_request, build_get_at_resource_group_level_request, build_get_at_resource_level_request, build_get_at_subscription_level_request, build_get_by_scope_request, build_list_at_resource_group_level_request, build_list_at_resource_level_request, build_list_at_subscription_level_request, build_list_by_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update_at_resource_group_level( self, resource_group_name: str, @@ -72,32 +78,22 @@ async def create_or_update_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -115,8 +111,11 @@ async def create_or_update_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_resource_group_level( self, resource_group_name: str, @@ -143,25 +142,17 @@ async def delete_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -174,6 +165,8 @@ async def delete_at_resource_group_level( delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get_at_resource_group_level( self, resource_group_name: str, @@ -196,27 +189,17 @@ async def get_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,8 +213,11 @@ async def get_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def create_or_update_by_scope( self, scope: str, @@ -261,31 +247,21 @@ async def create_or_update_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_scope_request( + scope=scope, + lock_name=lock_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -303,8 +279,11 @@ async def create_or_update_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_by_scope( self, scope: str, @@ -327,24 +306,16 @@ async def delete_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_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] + + request = build_delete_by_scope_request( + scope=scope, + lock_name=lock_name, + template_url=self.delete_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -357,6 +328,8 @@ async def delete_by_scope( delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get_by_scope( self, scope: str, @@ -379,26 +352,16 @@ async def get_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_scope_request( + scope=scope, + lock_name=lock_name, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -412,8 +375,11 @@ async def get_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_resource_level( self, resource_group_name: str, @@ -457,36 +423,26 @@ async def create_or_update_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -504,8 +460,11 @@ async def create_or_update_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_resource_level( self, resource_group_name: str, @@ -546,29 +505,21 @@ async def delete_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -581,6 +532,8 @@ async def delete_at_resource_level( delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get_at_resource_level( self, resource_group_name: str, @@ -616,31 +569,21 @@ async def get_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -654,8 +597,11 @@ async def get_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_subscription_level( self, lock_name: str, @@ -684,31 +630,21 @@ async def create_or_update_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -726,8 +662,11 @@ async def create_or_update_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def delete_at_subscription_level( self, lock_name: str, @@ -751,24 +690,16 @@ async def delete_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -781,6 +712,8 @@ async def delete_at_subscription_level( delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace_async async def get_at_subscription_level( self, lock_name: str, @@ -800,26 +733,16 @@ async def get_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -833,8 +756,11 @@ async def get_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def list_at_resource_group_level( self, resource_group_name: str, @@ -848,8 +774,10 @@ def list_at_resource_group_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -857,37 +785,33 @@ def list_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_resource_group_level.metadata['url'] # type: 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] - 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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_group_level.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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -905,11 +829,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_resource_level( self, resource_group_name: str, @@ -936,8 +862,10 @@ def list_at_resource_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -945,41 +873,41 @@ def list_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_level.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -997,11 +925,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_subscription_level( self, filter: Optional[str] = None, @@ -1012,8 +942,10 @@ def list_at_subscription_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -1021,36 +953,31 @@ def list_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_subscription_level.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] - 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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription_level.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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1068,11 +995,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_by_scope( self, scope: str, @@ -1090,8 +1019,10 @@ def list_by_scope( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -1099,36 +1030,31 @@ def list_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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_scope_request( + scope=scope, + filter=filter, + template_url=self.list_by_scope.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_scope_request( + scope=scope, + 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('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1146,6 +1072,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py index 13e07a006cbaa..67b85cfc2c301 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_management_lock_client_enums.py @@ -6,27 +6,12 @@ # 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 LockLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models.py index a34b7d07ec8a4..c139ef2a8b88a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models.py @@ -12,10 +12,10 @@ class ManagementLockListResult(msrest.serialization.Model): """The list of locks. - :param value: The list of locks. - :type value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The list of locks. + :vartype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of locks. + :paramtype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ManagementLockListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -45,15 +51,15 @@ class ManagementLockObject(msrest.serialization.Model): :vartype type: str :ivar name: The name of the lock. :vartype name: str - :param level: Required. The level of the lock. Possible values are: NotSpecified, CanNotDelete, + :ivar level: Required. The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", "ReadOnly". - :type level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel - :param notes: Notes about the lock. Maximum of 512 characters. - :type notes: str - :param owners: The owners of the lock. - :type owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] + :vartype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel + :ivar notes: Notes about the lock. Maximum of 512 characters. + :vartype notes: str + :ivar owners: The owners of the lock. + :vartype owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] """ _validation = { @@ -76,6 +82,18 @@ def __init__( self, **kwargs ): + """ + :keyword level: Required. The level of the lock. Possible values are: NotSpecified, + CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the + resources, but not delete. ReadOnly means authorized users can only read from a resource, but + they can't modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", + "ReadOnly". + :paramtype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel + :keyword notes: Notes about the lock. Maximum of 512 characters. + :paramtype notes: str + :keyword owners: The owners of the lock. + :paramtype owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] + """ super(ManagementLockObject, self).__init__(**kwargs) self.id = None self.type = None @@ -88,8 +106,8 @@ def __init__( class ManagementLockOwner(msrest.serialization.Model): """Lock owner properties. - :param application_id: The application ID of the lock owner. - :type application_id: str + :ivar application_id: The application ID of the lock owner. + :vartype application_id: str """ _attribute_map = { @@ -100,6 +118,10 @@ def __init__( self, **kwargs ): + """ + :keyword application_id: The application ID of the lock owner. + :paramtype application_id: str + """ super(ManagementLockOwner, self).__init__(**kwargs) self.application_id = kwargs.get('application_id', None) @@ -107,10 +129,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Authorization operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -122,6 +144,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -130,12 +158,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Authorization. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Authorization. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -148,6 +176,14 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Authorization. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -157,10 +193,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Authorization operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Authorization operations. - :type value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Authorization operations. + :vartype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -172,6 +208,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Authorization operations. + :paramtype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py index 1f84c9c1b7590..a011c7f0be503 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_models_py3.py @@ -16,10 +16,10 @@ class ManagementLockListResult(msrest.serialization.Model): """The list of locks. - :param value: The list of locks. - :type value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The list of locks. + :vartype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of locks. + :paramtype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ManagementLockListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -52,15 +58,15 @@ class ManagementLockObject(msrest.serialization.Model): :vartype type: str :ivar name: The name of the lock. :vartype name: str - :param level: Required. The level of the lock. Possible values are: NotSpecified, CanNotDelete, + :ivar level: Required. The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", "ReadOnly". - :type level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel - :param notes: Notes about the lock. Maximum of 512 characters. - :type notes: str - :param owners: The owners of the lock. - :type owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] + :vartype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel + :ivar notes: Notes about the lock. Maximum of 512 characters. + :vartype notes: str + :ivar owners: The owners of the lock. + :vartype owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] """ _validation = { @@ -87,6 +93,18 @@ def __init__( owners: Optional[List["ManagementLockOwner"]] = None, **kwargs ): + """ + :keyword level: Required. The level of the lock. Possible values are: NotSpecified, + CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the + resources, but not delete. ReadOnly means authorized users can only read from a resource, but + they can't modify or delete it. Possible values include: "NotSpecified", "CanNotDelete", + "ReadOnly". + :paramtype level: str or ~azure.mgmt.resource.locks.v2016_09_01.models.LockLevel + :keyword notes: Notes about the lock. Maximum of 512 characters. + :paramtype notes: str + :keyword owners: The owners of the lock. + :paramtype owners: list[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockOwner] + """ super(ManagementLockObject, self).__init__(**kwargs) self.id = None self.type = None @@ -99,8 +117,8 @@ def __init__( class ManagementLockOwner(msrest.serialization.Model): """Lock owner properties. - :param application_id: The application ID of the lock owner. - :type application_id: str + :ivar application_id: The application ID of the lock owner. + :vartype application_id: str """ _attribute_map = { @@ -113,6 +131,10 @@ def __init__( application_id: Optional[str] = None, **kwargs ): + """ + :keyword application_id: The application ID of the lock owner. + :paramtype application_id: str + """ super(ManagementLockOwner, self).__init__(**kwargs) self.application_id = application_id @@ -120,10 +142,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Authorization operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -138,6 +160,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -146,12 +174,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Authorization. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Authorization. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -168,6 +196,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Authorization. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, 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 @@ -177,10 +213,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Authorization operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Authorization operations. - :type value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Authorization operations. + :vartype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -195,6 +231,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Authorization operations. + :paramtype value: list[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py index 048fc64e4beeb..858994fe4cfe6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/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 + ) + +# fmt: on class AuthorizationOperationsOperations(object): """AuthorizationOperationsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.locks.v2016_09_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_management_locks_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_management_locks_operations.py index ba7a1c8feb728..f7cb045ad9be5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_management_locks_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_management_locks_operations.py @@ -5,24 +5,624 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_resource_group_level_request( + resource_group_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "lockName": _SERIALIZER.url("lock_name", lock_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_by_scope_request( + scope, # type: str + lock_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_by_scope_request( + scope, # type: str + lock_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_by_scope_request( + scope, # type: str + lock_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "lockName": _SERIALIZER.url("lock_name", lock_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_at_subscription_level_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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, + **kwargs + ) + + +def build_delete_at_subscription_level_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_subscription_level_request( + lock_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}') + path_format_arguments = { + "lockName": _SERIALIZER.url("lock_name", lock_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_at_resource_group_level_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks') + 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] + 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_list_at_resource_level_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_at_subscription_level_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks') + 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] + 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_list_by_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/locks') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, '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 + ) + +# fmt: on class ManagementLocksOperations(object): """ManagementLocksOperations operations. @@ -45,6 +645,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update_at_resource_group_level( self, resource_group_name, # type: str @@ -77,32 +678,22 @@ def create_or_update_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -120,8 +711,11 @@ def create_or_update_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_resource_group_level( self, resource_group_name, # type: str @@ -149,25 +743,17 @@ def delete_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -180,6 +766,8 @@ def delete_at_resource_group_level( delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get_at_resource_group_level( self, resource_group_name, # type: str @@ -203,27 +791,17 @@ def get_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_group_level_request( + resource_group_name=resource_group_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_group_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -237,8 +815,11 @@ def get_at_resource_group_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def create_or_update_by_scope( self, scope, # type: str @@ -269,31 +850,21 @@ def create_or_update_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_scope_request( + scope=scope, + lock_name=lock_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -311,8 +882,11 @@ def create_or_update_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_by_scope( self, scope, # type: str @@ -336,24 +910,16 @@ def delete_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_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] + + request = build_delete_by_scope_request( + scope=scope, + lock_name=lock_name, + template_url=self.delete_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -366,6 +932,8 @@ def delete_by_scope( delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get_by_scope( self, scope, # type: str @@ -389,26 +957,16 @@ def get_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_scope_request( + scope=scope, + lock_name=lock_name, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -422,8 +980,11 @@ def get_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def create_or_update_at_resource_level( self, resource_group_name, # type: str @@ -468,36 +1029,26 @@ def create_or_update_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -515,8 +1066,11 @@ def create_or_update_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_resource_level( self, resource_group_name, # type: str @@ -558,29 +1112,21 @@ def delete_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -593,6 +1139,8 @@ def delete_at_resource_level( delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get_at_resource_level( self, resource_group_name, # type: str @@ -629,31 +1177,21 @@ def get_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_resource_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -667,8 +1205,11 @@ def get_at_resource_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def create_or_update_at_subscription_level( self, lock_name, # type: str @@ -698,31 +1239,21 @@ def create_or_update_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ManagementLockObject') + + request = build_create_or_update_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementLockObject') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -740,8 +1271,11 @@ def create_or_update_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def delete_at_subscription_level( self, lock_name, # type: str @@ -766,24 +1300,16 @@ def delete_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.delete_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,6 +1322,8 @@ def delete_at_subscription_level( delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def get_at_subscription_level( self, lock_name, # type: str @@ -816,26 +1344,16 @@ def get_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'lockName': self._serialize.url("lock_name", lock_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_level_request( + lock_name=lock_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_level.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -849,8 +1367,11 @@ def get_at_subscription_level( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + @distributed_trace def list_at_resource_group_level( self, resource_group_name, # type: str @@ -865,8 +1386,10 @@ def list_at_resource_group_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -874,37 +1397,33 @@ def list_at_resource_group_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_resource_group_level.metadata['url'] # type: 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] - 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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_group_level.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_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -922,11 +1441,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_resource_level( self, resource_group_name, # type: str @@ -954,8 +1475,10 @@ def list_at_resource_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -963,41 +1486,41 @@ def list_at_resource_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_resource_level.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_resource_level.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_at_resource_level_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1015,11 +1538,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_at_subscription_level( self, filter=None, # type: Optional[str] @@ -1031,8 +1556,10 @@ def list_at_subscription_level( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -1040,36 +1567,31 @@ def list_at_subscription_level( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_at_subscription_level.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] - 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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_at_subscription_level.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_at_subscription_level_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1087,11 +1609,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore + @distributed_trace def list_by_scope( self, scope, # type: str @@ -1110,8 +1634,10 @@ def list_by_scope( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementLockListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] + :return: An iterator like instance of either ManagementLockListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementLockListResult"] @@ -1119,36 +1645,31 @@ def list_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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_scope_request( + scope=scope, + filter=filter, + template_url=self.list_by_scope.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_scope_request( + scope=scope, + 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('ManagementLockListResult', pipeline_response) + deserialized = self._deserialize("ManagementLockListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1166,6 +1687,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py index f9cb5173aa33e..624aa2175b55c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApplicationClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py index 891e957a67f62..8fddb2b269ada 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_application_client.py @@ -6,80 +6,87 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApplicationClientConfiguration -from .operations import ApplicationClientOperationsMixin -from .operations import ApplicationsOperations -from .operations import ApplicationDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ApplicationClient(ApplicationClientOperationsMixin): """ARM applications. :ivar applications: ApplicationsOperations operations - :vartype applications: azure.mgmt.resource.managedapplications.operations.ApplicationsOperations + :vartype applications: + azure.mgmt.resource.managedapplications.operations.ApplicationsOperations :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: azure.mgmt.resource.managedapplications.operations.ApplicationDefinitionsOperations + :vartype application_definitions: + azure.mgmt.resource.managedapplications.operations.ApplicationDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py index 41a2247f3dd8b..60bbbddc50964 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ApplicationClientConfiguration, 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(ApplicationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json index cbc4f9791d8c5..2824baa770dfb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json @@ -5,13 +5,13 @@ "name": "ApplicationClient", "filename": "_application_client", "description": "ARM applications.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApplicationClientConfiguration\"], \"._operations_mixin\": [\"ApplicationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,29 +91,28 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "applications": "ApplicationsOperations", "application_definitions": "ApplicationDefinitionsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}, \"azurecore\": {\"azure.core.paging\": [\"ItemPaged\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}, \"azurecore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\u003e Iterable[\"_models.OperationListResult\"]\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": false, - "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.OperationListResult\"]:\n", - "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def list_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.OperationListResult\"]:\n", + "doc": "\"\"\"Lists all of the available Microsoft.Solutions REST API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either OperationListResult or the result of cls(response)\n:rtype:\n ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py index 42ac8700d5dff..45c4790ba3ab1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py @@ -8,3 +8,8 @@ from ._application_client import ApplicationClient __all__ = ['ApplicationClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py index 4f51221f18def..4862cf6773061 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client.py @@ -6,76 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ApplicationClientConfiguration +from .operations import ApplicationClientOperationsMixin, ApplicationDefinitionsOperations, ApplicationsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApplicationClientConfiguration -from .operations import ApplicationClientOperationsMixin -from .operations import ApplicationsOperations -from .operations import ApplicationDefinitionsOperations -from .. import models - - class ApplicationClient(ApplicationClientOperationsMixin): """ARM applications. :ivar applications: ApplicationsOperations operations - :vartype applications: azure.mgmt.resource.managedapplications.aio.operations.ApplicationsOperations + :vartype applications: + azure.mgmt.resource.managedapplications.aio.operations.ApplicationsOperations :ivar application_definitions: ApplicationDefinitionsOperations operations - :vartype application_definitions: azure.mgmt.resource.managedapplications.aio.operations.ApplicationDefinitionsOperations + :vartype application_definitions: + azure.mgmt.resource.managedapplications.aio.operations.ApplicationDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ApplicationClientConfiguration(credential, subscription_id, **kwargs) + self._config = ApplicationClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.application_definitions = ApplicationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py index c997edfe9d5d5..098ad4a387094 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApplicationClientConfiguration, 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(ApplicationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/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/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_client_operations.py index 79f939e8e841f..096723f1ee32c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_client_operations.py @@ -5,22 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._application_client_operations import build_list_operations_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApplicationClientOperationsMixin: + @distributed_trace def list_operations( self, **kwargs: Any @@ -29,7 +35,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -37,30 +44,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -78,6 +82,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_definitions_operations.py index c857b105d5f04..69d3342670413 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_application_definitions_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._application_definitions_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,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, @@ -65,33 +71,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -115,40 +113,31 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -163,15 +152,17 @@ async def begin_delete( :type application_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -185,21 +176,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -211,6 +195,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore async def _create_or_update_initial( @@ -225,39 +210,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApplicationDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ApplicationDefinition', pipeline_response) @@ -269,8 +243,11 @@ 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.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -289,15 +266,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :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. + :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 ApplicationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :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 ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -309,27 +291,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, application_definition_name=application_definition_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApplicationDefinition', 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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -341,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -353,8 +331,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinitionListResult"] @@ -362,35 +342,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationDefinitionListResult', pipeline_response) + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -403,17 +379,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Solutions/applicationDefinitions'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_group_name: str, @@ -436,33 +414,23 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -473,8 +441,10 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + async def _delete_by_id_initial( self, resource_group_name: str, @@ -486,40 +456,31 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_by_id_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_by_id_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_group_name: str, @@ -534,15 +495,17 @@ async def begin_delete_by_id( :type application_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -556,21 +519,14 @@ async def begin_delete_by_id( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -582,6 +538,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore async def _create_or_update_by_id_initial( @@ -596,39 +553,28 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_by_id_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApplicationDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ApplicationDefinition', pipeline_response) @@ -640,8 +586,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_group_name: str, @@ -660,15 +609,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :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. + :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 ApplicationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :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 ApplicationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -680,27 +634,21 @@ async def begin_create_or_update_by_id( resource_group_name=resource_group_name, application_definition_name=application_definition_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApplicationDefinition', 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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -712,4 +660,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_applications_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_applications_operations.py index 5f14cf1cea5d3..4fde6f3b903f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_applications_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations/_applications_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._applications_operations import build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_by_id_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,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, @@ -65,33 +71,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -115,40 +113,31 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -163,15 +152,17 @@ async def begin_delete( :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -185,21 +176,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - '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: @@ -211,6 +195,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore async def _create_or_update_initial( @@ -225,39 +210,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Application') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Application', pipeline_response) @@ -269,8 +243,11 @@ 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.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -288,15 +265,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.managedapplications.models.Application :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. + :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 Application or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :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 Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] lro_delay = kwargs.pop( 'polling_interval', @@ -308,27 +290,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, application_name=application_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Application', 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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - '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: @@ -340,8 +316,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -368,41 +346,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ApplicationPatchable') + _json = self._serialize.body(parameters, 'ApplicationPatchable') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Application', pipeline_response) @@ -411,8 +379,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -423,8 +394,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] @@ -432,35 +405,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -473,17 +442,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Solutions/applications'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -491,8 +462,10 @@ def list_by_subscription( """Gets all the applications within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] @@ -500,34 +473,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,17 +508,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications'} # type: ignore + @distributed_trace_async async def get_by_id( self, application_id: str, @@ -572,31 +542,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + application_id=application_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -607,8 +567,10 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + async def _delete_by_id_initial( self, application_id: str, @@ -619,38 +581,29 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + application_id=application_id, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, application_id: str, @@ -664,15 +617,17 @@ async def begin_delete_by_id( :type application_id: 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -685,19 +640,14 @@ async def begin_delete_by_id( 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 = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - 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: @@ -709,6 +659,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{applicationId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -722,37 +673,26 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Application') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Application', pipeline_response) @@ -764,8 +704,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, application_id: str, @@ -782,15 +725,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.managedapplications.models.Application :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. + :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 Application or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :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 Application or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.managedapplications.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] lro_delay = kwargs.pop( 'polling_interval', @@ -801,25 +749,21 @@ async def begin_create_or_update_by_id( raw_result = await self._create_or_update_by_id_initial( application_id=application_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Application', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - 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: @@ -831,8 +775,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + @distributed_trace_async async def update_by_id( self, application_id: str, @@ -858,39 +804,29 @@ async def update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'Application') + _json = self._serialize.body(parameters, 'Application') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_by_id_request( + application_id=application_id, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Application', pipeline_response) @@ -899,4 +835,6 @@ async def update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py index 087d36dbf3a87..c7b8d511ee5cb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_application_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 ApplicationArtifactType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApplicationArtifactType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The managed application artifact type. """ TEMPLATE = "Template" CUSTOM = "Custom" -class ApplicationLockLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApplicationLockLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The managed application lock level. """ @@ -41,7 +26,7 @@ class ApplicationLockLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" NONE = "None" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning status of the managed application. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models.py index ff5a88fc66383..5418da6e00df3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models.py @@ -21,10 +21,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -45,6 +45,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -64,16 +70,16 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity """ _validation = { @@ -97,6 +103,18 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.managed_by = kwargs.get('managed_by', None) self.sku = kwargs.get('sku', None) @@ -116,29 +134,28 @@ class Application(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param plan: The plan information. - :type plan: ~azure.mgmt.resource.managedapplications.models.Plan - :param kind: Required. The kind of the managed application. Allowed values are MarketPlace and + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.resource.managedapplications.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. - :type kind: str - :param managed_resource_group_id: Required. The managed resource group Id. - :type managed_resource_group_id: str - :param application_definition_id: The fully qualified path of managed application definition - Id. - :type application_definition_id: str - :param parameters: Name and value pairs that define the managed application parameters. It can + :vartype kind: str + :ivar managed_resource_group_id: Required. The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :type parameters: any + :vartype parameters: any :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: any :ivar provisioning_state: The managed application provisioning state. Possible values include: @@ -180,6 +197,31 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.resource.managedapplications.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: Required. The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ super(Application, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.kind = kwargs['kind'] @@ -193,13 +235,13 @@ def __init__( class ApplicationArtifact(msrest.serialization.Model): """Managed application artifact. - :param name: The managed application artifact name. - :type name: str - :param uri: The managed application artifact blob uri. - :type uri: str - :param type: The managed application artifact type. Possible values include: "Template", + :ivar name: The managed application artifact name. + :vartype name: str + :ivar uri: The managed application artifact blob uri. + :vartype uri: str + :ivar type: The managed application artifact type. Possible values include: "Template", "Custom". - :type type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :vartype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType """ _attribute_map = { @@ -212,6 +254,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: The managed application artifact name. + :paramtype name: str + :keyword uri: The managed application artifact blob uri. + :paramtype uri: str + :keyword type: The managed application artifact type. Possible values include: "Template", + "Custom". + :paramtype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + """ super(ApplicationArtifact, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.uri = kwargs.get('uri', None) @@ -231,40 +282,41 @@ class ApplicationDefinition(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param lock_level: Required. The managed application lock level. Possible values include: + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar lock_level: Required. The managed application lock level. Possible values include: "CanNotDelete", "ReadOnly", "None". - :type lock_level: str or ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel - :param display_name: The managed application definition display name. - :type display_name: str - :param is_enabled: A value indicating whether the package is enabled or not. - :type is_enabled: str - :param authorizations: Required. The managed application provider authorizations. - :type authorizations: + :vartype lock_level: str or + ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: str + :ivar authorizations: Required. The managed application provider authorizations. + :vartype authorizations: list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] - :param artifacts: The collection of managed application artifacts. The portal will use the - files specified as artifacts to construct the user experience of creating a managed application - from a managed application definition. - :type artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] - :param description: The managed application definition description. - :type description: str - :param package_file_uri: The managed application definition package file Uri. Use this element. - :type package_file_uri: str - :param main_template: The inline main template json which has resources to be provisioned. It + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string. - :type main_template: any - :param create_ui_definition: The createUiDefinition json for the backing template with + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :type create_ui_definition: any + :vartype create_ui_definition: any """ _validation = { @@ -299,6 +351,44 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword lock_level: Required. The managed application lock level. Possible values include: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: str + :keyword authorizations: Required. The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + """ super(ApplicationDefinition, self).__init__(**kwargs) self.lock_level = kwargs['lock_level'] self.display_name = kwargs.get('display_name', None) @@ -314,10 +404,10 @@ def __init__( class ApplicationDefinitionListResult(msrest.serialization.Model): """List of managed application definitions. - :param value: The array of managed application definitions. - :type value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -329,6 +419,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ApplicationDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -337,10 +433,10 @@ def __init__( class ApplicationListResult(msrest.serialization.Model): """List of managed applications. - :param value: The array of managed applications. - :type value: list[~azure.mgmt.resource.managedapplications.models.Application] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -352,6 +448,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ApplicationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -368,29 +470,28 @@ class ApplicationPatchable(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param plan: The plan information. - :type plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable - :param kind: The kind of the managed application. Allowed values are MarketPlace and + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. - :type kind: str - :param managed_resource_group_id: The managed resource group Id. - :type managed_resource_group_id: str - :param application_definition_id: The fully qualified path of managed application definition - Id. - :type application_definition_id: str - :param parameters: Name and value pairs that define the managed application parameters. It can + :vartype kind: str + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :type parameters: any + :vartype parameters: any :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: any :ivar provisioning_state: The managed application provisioning state. Possible values include: @@ -431,6 +532,31 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ super(ApplicationPatchable, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.kind = kwargs.get('kind', None) @@ -446,13 +572,13 @@ class ApplicationProviderAuthorization(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param principal_id: Required. The provider's principal identifier. This is the identity that + :ivar principal_id: Required. The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the managed application resources. - :type principal_id: str - :param role_definition_id: Required. The provider's role definition identifier. This role will + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will define all the permissions that the provider must have on the managed application's container resource group. This role definition cannot have permission to delete the resource group. - :type role_definition_id: str + :vartype role_definition_id: str """ _validation = { @@ -469,6 +595,16 @@ def __init__( self, **kwargs ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ super(ApplicationProviderAuthorization, self).__init__(**kwargs) self.principal_id = kwargs['principal_id'] self.role_definition_id = kwargs['role_definition_id'] @@ -477,12 +613,12 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates managed application is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -495,6 +631,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -510,9 +654,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -530,6 +674,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -539,10 +688,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Solutions operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay """ _attribute_map = { @@ -554,6 +703,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -562,12 +717,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Solutions. - :type provider: str - :param resource: Resource on which the operation is performed: Application, JitRequest, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -580,6 +735,14 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -589,10 +752,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Solutions operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Solutions operations. - :type value: list[~azure.mgmt.resource.managedapplications.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Solutions operations. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -604,6 +767,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Solutions operations. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -614,16 +783,16 @@ class Plan(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The plan name. - :type name: str - :param publisher: Required. The publisher ID. - :type publisher: str - :param product: Required. The product code. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: Required. The plan's version. - :type version: str + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str """ _validation = { @@ -645,6 +814,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs['name'] self.publisher = kwargs['publisher'] @@ -656,16 +837,16 @@ def __init__( class PlanPatchable(msrest.serialization.Model): """Plan for the managed application. - :param name: The plan name. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The product code. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -680,6 +861,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(PlanPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -693,18 +886,18 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _validation = { @@ -724,6 +917,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py index a4cada4db25e3..61738cf790e89 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_models_py3.py @@ -25,10 +25,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -52,6 +52,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -71,16 +77,16 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity """ _validation = { @@ -110,6 +116,18 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.managed_by = managed_by self.sku = sku @@ -129,29 +147,28 @@ class Application(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param plan: The plan information. - :type plan: ~azure.mgmt.resource.managedapplications.models.Plan - :param kind: Required. The kind of the managed application. Allowed values are MarketPlace and + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.resource.managedapplications.models.Plan + :ivar kind: Required. The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. - :type kind: str - :param managed_resource_group_id: Required. The managed resource group Id. - :type managed_resource_group_id: str - :param application_definition_id: The fully qualified path of managed application definition - Id. - :type application_definition_id: str - :param parameters: Name and value pairs that define the managed application parameters. It can + :vartype kind: str + :ivar managed_resource_group_id: Required. The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :type parameters: any + :vartype parameters: any :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: any :ivar provisioning_state: The managed application provisioning state. Possible values include: @@ -204,6 +221,31 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.resource.managedapplications.models.Plan + :keyword kind: Required. The kind of the managed application. Allowed values are MarketPlace + and ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: Required. The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.plan = plan self.kind = kind @@ -217,13 +259,13 @@ def __init__( class ApplicationArtifact(msrest.serialization.Model): """Managed application artifact. - :param name: The managed application artifact name. - :type name: str - :param uri: The managed application artifact blob uri. - :type uri: str - :param type: The managed application artifact type. Possible values include: "Template", + :ivar name: The managed application artifact name. + :vartype name: str + :ivar uri: The managed application artifact blob uri. + :vartype uri: str + :ivar type: The managed application artifact type. Possible values include: "Template", "Custom". - :type type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :vartype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType """ _attribute_map = { @@ -240,6 +282,15 @@ def __init__( type: Optional[Union[str, "ApplicationArtifactType"]] = None, **kwargs ): + """ + :keyword name: The managed application artifact name. + :paramtype name: str + :keyword uri: The managed application artifact blob uri. + :paramtype uri: str + :keyword type: The managed application artifact type. Possible values include: "Template", + "Custom". + :paramtype type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + """ super(ApplicationArtifact, self).__init__(**kwargs) self.name = name self.uri = uri @@ -259,40 +310,41 @@ class ApplicationDefinition(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param lock_level: Required. The managed application lock level. Possible values include: + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar lock_level: Required. The managed application lock level. Possible values include: "CanNotDelete", "ReadOnly", "None". - :type lock_level: str or ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel - :param display_name: The managed application definition display name. - :type display_name: str - :param is_enabled: A value indicating whether the package is enabled or not. - :type is_enabled: str - :param authorizations: Required. The managed application provider authorizations. - :type authorizations: + :vartype lock_level: str or + ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :ivar display_name: The managed application definition display name. + :vartype display_name: str + :ivar is_enabled: A value indicating whether the package is enabled or not. + :vartype is_enabled: str + :ivar authorizations: Required. The managed application provider authorizations. + :vartype authorizations: list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] - :param artifacts: The collection of managed application artifacts. The portal will use the - files specified as artifacts to construct the user experience of creating a managed application - from a managed application definition. - :type artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] - :param description: The managed application definition description. - :type description: str - :param package_file_uri: The managed application definition package file Uri. Use this element. - :type package_file_uri: str - :param main_template: The inline main template json which has resources to be provisioned. It + :ivar artifacts: The collection of managed application artifacts. The portal will use the files + specified as artifacts to construct the user experience of creating a managed application from + a managed application definition. + :vartype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :ivar description: The managed application definition description. + :vartype description: str + :ivar package_file_uri: The managed application definition package file Uri. Use this element. + :vartype package_file_uri: str + :ivar main_template: The inline main template json which has resources to be provisioned. It can be a JObject or well-formed JSON string. - :type main_template: any - :param create_ui_definition: The createUiDefinition json for the backing template with + :vartype main_template: any + :ivar create_ui_definition: The createUiDefinition json for the backing template with Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. - :type create_ui_definition: any + :vartype create_ui_definition: any """ _validation = { @@ -342,6 +394,44 @@ def __init__( create_ui_definition: Optional[Any] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword lock_level: Required. The managed application lock level. Possible values include: + "CanNotDelete", "ReadOnly", "None". + :paramtype lock_level: str or + ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :keyword display_name: The managed application definition display name. + :paramtype display_name: str + :keyword is_enabled: A value indicating whether the package is enabled or not. + :paramtype is_enabled: str + :keyword authorizations: Required. The managed application provider authorizations. + :paramtype authorizations: + list[~azure.mgmt.resource.managedapplications.models.ApplicationProviderAuthorization] + :keyword artifacts: The collection of managed application artifacts. The portal will use the + files specified as artifacts to construct the user experience of creating a managed application + from a managed application definition. + :paramtype artifacts: list[~azure.mgmt.resource.managedapplications.models.ApplicationArtifact] + :keyword description: The managed application definition description. + :paramtype description: str + :keyword package_file_uri: The managed application definition package file Uri. Use this + element. + :paramtype package_file_uri: str + :keyword main_template: The inline main template json which has resources to be provisioned. It + can be a JObject or well-formed JSON string. + :paramtype main_template: any + :keyword create_ui_definition: The createUiDefinition json for the backing template with + Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string. + :paramtype create_ui_definition: any + """ super(ApplicationDefinition, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.lock_level = lock_level self.display_name = display_name @@ -357,10 +447,10 @@ def __init__( class ApplicationDefinitionListResult(msrest.serialization.Model): """List of managed application definitions. - :param value: The array of managed application definitions. - :type value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of managed application definitions. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -375,6 +465,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of managed application definitions. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ApplicationDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -383,10 +479,10 @@ def __init__( class ApplicationListResult(msrest.serialization.Model): """List of managed applications. - :param value: The array of managed applications. - :type value: list[~azure.mgmt.resource.managedapplications.models.Application] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of managed applications. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -401,6 +497,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of managed applications. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Application] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ApplicationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -417,29 +519,28 @@ class ApplicationPatchable(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.managedapplications.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.managedapplications.models.Identity - :param plan: The plan information. - :type plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable - :param kind: The kind of the managed application. Allowed values are MarketPlace and + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :ivar plan: The plan information. + :vartype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :ivar kind: The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. - :type kind: str - :param managed_resource_group_id: The managed resource group Id. - :type managed_resource_group_id: str - :param application_definition_id: The fully qualified path of managed application definition - Id. - :type application_definition_id: str - :param parameters: Name and value pairs that define the managed application parameters. It can + :vartype kind: str + :ivar managed_resource_group_id: The managed resource group Id. + :vartype managed_resource_group_id: str + :ivar application_definition_id: The fully qualified path of managed application definition Id. + :vartype application_definition_id: str + :ivar parameters: Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - :type parameters: any + :vartype parameters: any :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: any :ivar provisioning_state: The managed application provisioning state. Possible values include: @@ -491,6 +592,31 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.managedapplications.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.managedapplications.models.Identity + :keyword plan: The plan information. + :paramtype plan: ~azure.mgmt.resource.managedapplications.models.PlanPatchable + :keyword kind: The kind of the managed application. Allowed values are MarketPlace and + ServiceCatalog. + :paramtype kind: str + :keyword managed_resource_group_id: The managed resource group Id. + :paramtype managed_resource_group_id: str + :keyword application_definition_id: The fully qualified path of managed application definition + Id. + :paramtype application_definition_id: str + :keyword parameters: Name and value pairs that define the managed application parameters. It + can be a JObject or a well formed JSON string. + :paramtype parameters: any + """ super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.plan = plan self.kind = kind @@ -506,13 +632,13 @@ class ApplicationProviderAuthorization(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param principal_id: Required. The provider's principal identifier. This is the identity that + :ivar principal_id: Required. The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the managed application resources. - :type principal_id: str - :param role_definition_id: Required. The provider's role definition identifier. This role will + :vartype principal_id: str + :ivar role_definition_id: Required. The provider's role definition identifier. This role will define all the permissions that the provider must have on the managed application's container resource group. This role definition cannot have permission to delete the resource group. - :type role_definition_id: str + :vartype role_definition_id: str """ _validation = { @@ -532,6 +658,16 @@ def __init__( role_definition_id: str, **kwargs ): + """ + :keyword principal_id: Required. The provider's principal identifier. This is the identity that + the provider will use to call ARM to manage the managed application resources. + :paramtype principal_id: str + :keyword role_definition_id: Required. The provider's role definition identifier. This role + will define all the permissions that the provider must have on the managed application's + container resource group. This role definition cannot have permission to delete the resource + group. + :paramtype role_definition_id: str + """ super(ApplicationProviderAuthorization, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -540,12 +676,12 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates managed application is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -562,6 +698,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -577,9 +721,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -599,6 +743,11 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -608,10 +757,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Solutions operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay """ _attribute_map = { @@ -626,6 +775,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.managedapplications.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -634,12 +789,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Solutions. - :type provider: str - :param resource: Resource on which the operation is performed: Application, JitRequest, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Solutions. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Application, JitRequest, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -656,6 +811,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Solutions. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Application, JitRequest, 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 @@ -665,10 +828,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Solutions operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Solutions operations. - :type value: list[~azure.mgmt.resource.managedapplications.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Solutions operations. + :vartype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -683,6 +846,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Solutions operations. + :paramtype value: list[~azure.mgmt.resource.managedapplications.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -693,16 +862,16 @@ class Plan(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The plan name. - :type name: str - :param publisher: Required. The publisher ID. - :type publisher: str - :param product: Required. The product code. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: Required. The plan's version. - :type version: str + :ivar name: Required. The plan name. + :vartype name: str + :ivar publisher: Required. The publisher ID. + :vartype publisher: str + :ivar product: Required. The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: Required. The plan's version. + :vartype version: str """ _validation = { @@ -730,6 +899,18 @@ def __init__( promotion_code: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The plan name. + :paramtype name: str + :keyword publisher: Required. The publisher ID. + :paramtype publisher: str + :keyword product: Required. The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: Required. The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -741,16 +922,16 @@ def __init__( class PlanPatchable(msrest.serialization.Model): """Plan for the managed application. - :param name: The plan name. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The product code. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan name. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The product code. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -771,6 +952,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan name. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The product code. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(PlanPatchable, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -784,18 +977,18 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: Required. The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _validation = { @@ -822,6 +1015,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_client_operations.py index d8a9ac5a43483..c29e4d515c5ae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_client_operations.py @@ -5,26 +5,61 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_operations_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Solutions/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 + ) + +# fmt: on class ApplicationClientOperationsMixin(object): + @distributed_trace def list_operations( self, **kwargs # type: Any @@ -34,7 +69,8 @@ def list_operations( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -42,30 +78,27 @@ def list_operations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_operations.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_operations_request( + template_url=self.list_operations.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_operations_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -83,6 +116,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_definitions_operations.py index 96e0612e8fd31..c1102bb96e585 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_application_definitions_operations.py @@ -5,26 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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_initial( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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_create_or_update_request_initial( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions') + 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_get_by_id_request( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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_by_id_request_initial( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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_create_or_update_by_id_request_initial( + resource_group_name, # type: str + application_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationDefinitionName": _SERIALIZER.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), + "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, + **kwargs + ) + +# fmt: on class ApplicationDefinitionsOperations(object): """ApplicationDefinitionsOperations operations. @@ -47,6 +313,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -70,33 +337,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +364,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -121,40 +380,31 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -170,15 +420,17 @@ def begin_delete( :type application_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -192,21 +444,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -218,6 +463,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore def _create_or_update_initial( @@ -233,39 +479,28 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApplicationDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApplicationDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ApplicationDefinition', pipeline_response) @@ -277,8 +512,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -298,15 +536,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :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. + :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 ApplicationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :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 ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -318,27 +561,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, application_definition_name=application_definition_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApplicationDefinition', 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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -350,8 +587,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -363,8 +602,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] + :return: An iterator like instance of either ApplicationDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinitionListResult"] @@ -372,35 +613,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationDefinitionListResult', pipeline_response) + deserialized = self._deserialize("ApplicationDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -413,17 +650,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Solutions/applicationDefinitions'} # type: ignore + @distributed_trace def get_by_id( self, resource_group_name, # type: str @@ -447,33 +686,23 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -484,8 +713,10 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + def _delete_by_id_initial( self, resource_group_name, # type: str @@ -498,40 +729,31 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_by_id_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_by_id_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_group_name, # type: str @@ -547,15 +769,17 @@ def begin_delete_by_id( :type application_definition_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -569,21 +793,14 @@ def begin_delete_by_id( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -595,6 +812,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore def _create_or_update_by_id_initial( @@ -610,39 +828,28 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_by_id_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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApplicationDefinition') + + request = build_create_or_update_by_id_request_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApplicationDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ApplicationDefinition', pipeline_response) @@ -654,8 +861,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_group_name, # type: str @@ -675,15 +885,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition :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. + :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 ApplicationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :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 ApplicationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -695,27 +910,21 @@ def begin_create_or_update_by_id( resource_group_name=resource_group_name, application_definition_name=application_definition_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApplicationDefinition', 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\._\(\)]+$'), - 'applicationDefinitionName': self._serialize.url("application_definition_name", application_definition_name, 'str', max_length=64, min_length=3), - '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: @@ -727,4 +936,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_applications_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_applications_operations.py index 8ea24c2e4ba3b..d060a007ae743 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_applications_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/_applications_operations.py @@ -5,26 +5,388 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + application_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "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_initial( + resource_group_name, # type: str + application_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "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_create_or_update_request_initial( + resource_group_name, # type: str + application_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "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, + **kwargs + ) + + +def build_update_request( + resource_group_name, # type: str + application_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "applicationName": _SERIALIZER.url("application_name", application_name, 'str', max_length=64, min_length=3), + "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, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications') + 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_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications') + 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 + ) + + +def build_get_by_id_request( + application_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{applicationId}') + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_by_id_request_initial( + application_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{applicationId}') + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + application_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{applicationId}') + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request( + application_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{applicationId}') + path_format_arguments = { + "applicationId": _SERIALIZER.url("application_id", application_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class ApplicationsOperations(object): """ApplicationsOperations operations. @@ -47,6 +409,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -70,33 +433,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +460,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -121,40 +476,31 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -170,15 +516,17 @@ def begin_delete( :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -192,21 +540,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - '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: @@ -218,6 +559,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore def _create_or_update_initial( @@ -233,39 +575,28 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Application') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Application', pipeline_response) @@ -277,8 +608,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -297,15 +631,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.managedapplications.models.Application :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. + :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 Application or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :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 Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] lro_delay = kwargs.pop( 'polling_interval', @@ -317,27 +656,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, application_name=application_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Application', 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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - '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: @@ -349,8 +682,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + @distributed_trace def update( self, resource_group_name, # type: str @@ -378,41 +713,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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\._\(\)]+$'), - 'applicationName': self._serialize.url("application_name", application_name, 'str', max_length=64, min_length=3), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ApplicationPatchable') + _json = self._serialize.body(parameters, 'ApplicationPatchable') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Application', pipeline_response) @@ -421,8 +746,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -434,8 +762,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] @@ -443,35 +773,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -484,17 +810,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Solutions/applications'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -503,8 +831,10 @@ def list_by_subscription( """Gets all the applications within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] + :return: An iterator like instance of either ApplicationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.managedapplications.models.ApplicationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] @@ -512,34 +842,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_subscription.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_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -552,17 +877,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications'} # type: ignore + @distributed_trace def get_by_id( self, application_id, # type: str @@ -585,31 +912,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + application_id=application_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -620,8 +937,10 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + def _delete_by_id_initial( self, application_id, # type: str @@ -633,38 +952,29 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + application_id=application_id, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, application_id, # type: str @@ -679,15 +989,17 @@ def begin_delete_by_id( :type application_id: 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -700,19 +1012,14 @@ def begin_delete_by_id( 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 = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - 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: @@ -724,6 +1031,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{applicationId}'} # type: ignore def _create_or_update_by_id_initial( @@ -738,37 +1046,26 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Application') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + application_id=application_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Application') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Application', pipeline_response) @@ -780,8 +1077,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, application_id, # type: str @@ -799,15 +1099,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.managedapplications.models.Application :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. + :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 Application or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] - :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 Application or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.managedapplications.models.Application] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] lro_delay = kwargs.pop( 'polling_interval', @@ -818,25 +1123,21 @@ def begin_create_or_update_by_id( raw_result = self._create_or_update_by_id_initial( application_id=application_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Application', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - 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: @@ -848,8 +1149,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + @distributed_trace def update_by_id( self, application_id, # type: str @@ -876,39 +1179,29 @@ def update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'applicationId': self._serialize.url("application_id", application_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'Application') + _json = self._serialize.body(parameters, 'Application') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_by_id_request( + application_id=application_id, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Application', pipeline_response) @@ -917,4 +1210,6 @@ def update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py index 18ccc61af3b25..a042a5e21fb67 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py index b94a696cce82a..856511524e71b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/_policy_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -69,12 +68,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(PolicyClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py index 993b4f6076dd2..be542e6ae80e0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py index e40fa39b47e18..fb14097cd7cc1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/aio/_policy_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -67,12 +67,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(PolicyClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py index 2da5258390839..55b9b772e79d7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json index 7d43f5017374c..1b1cf4b6f9e63 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py index 37ab4a7bfc275..a952e404f31cb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_policy_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py index 08f40b9d35aaa..fa81a995062b2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py index d2433db00a327..729c56bd7a183 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_assignments_operations.py index f4bd0ddf1ec74..97fe7e1524af4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,26 +69,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -126,31 +125,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +153,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -188,26 +180,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -221,8 +203,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -236,8 +221,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -245,37 +232,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,11 +276,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -324,8 +309,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -333,41 +320,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -385,11 +372,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -400,8 +389,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -409,36 +400,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -456,11 +442,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -487,25 +475,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -519,8 +497,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -552,30 +533,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -589,8 +560,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -617,25 +591,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -649,4 +613,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_definitions_operations.py index 1d20c16ea1faf..550b0fd35909b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -63,31 +69,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyDefinition') + + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -122,24 +121,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -152,6 +143,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -171,26 +164,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,8 +187,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -216,8 +202,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -225,36 +213,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,6 +255,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models.py index fcb721f90b973..53d2c59d23059 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models.py @@ -12,18 +12,18 @@ class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :param id: The ID of the policy assignment. - :type id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str """ _attribute_map = { @@ -39,6 +39,20 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the policy assignment. + :paramtype id: str + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) @@ -51,10 +65,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -66,6 +80,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -78,18 +98,18 @@ class PolicyDefinition(msrest.serialization.Model): :ivar id: The ID of the policy definition. :vartype id: str - :param name: The name of the policy definition. If you do not specify a value for name, the + :ivar name: The name of the policy definition. If you do not specify a value for name, the value is inferred from the name value in the request URI. - :type name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :vartype name: str + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any """ _validation = { @@ -109,6 +129,21 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the policy definition. If you do not specify a value for name, the + value is inferred from the name value in the request URI. + :paramtype name: str + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -121,10 +156,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -136,6 +171,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py index 8a4027c8b4d3a..bbbad547ee0a8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_models_py3.py @@ -16,18 +16,18 @@ class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :param id: The ID of the policy assignment. - :type id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str """ _attribute_map = { @@ -50,6 +50,20 @@ def __init__( scope: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the policy assignment. + :paramtype id: str + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = id self.type = type @@ -62,10 +76,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -80,6 +94,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -92,18 +112,18 @@ class PolicyDefinition(msrest.serialization.Model): :ivar id: The ID of the policy definition. :vartype id: str - :param name: The name of the policy definition. If you do not specify a value for name, the + :ivar name: The name of the policy definition. If you do not specify a value for name, the value is inferred from the name value in the request URI. - :type name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :vartype name: str + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any """ _validation = { @@ -129,6 +149,21 @@ def __init__( policy_rule: Optional[Any] = None, **kwargs ): + """ + :keyword name: The name of the policy definition. If you do not specify a value for name, the + value is inferred from the name value in the request URI. + :paramtype name: str + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyType + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = name @@ -141,10 +176,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -159,6 +194,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py index 0e62b3fa1096c..b6d41257fadba 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_assignments_operations.py index dbc0dbc57b8dd..0de67e7f3977c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -68,26 +403,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +426,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -132,31 +460,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +488,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -195,26 +516,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -228,8 +539,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -244,8 +558,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -253,37 +569,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -301,11 +613,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -333,8 +647,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -342,41 +658,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -394,11 +710,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -410,8 +728,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -419,36 +739,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -466,11 +781,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -498,25 +815,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -530,8 +837,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -564,30 +874,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -601,8 +901,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -630,25 +933,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -662,4 +955,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_definitions_operations.py index 4f62c3d1a733c..b5f675f6312bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/_policy_definitions_operations.py @@ -5,24 +5,168 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-10-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions') + 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] + 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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +189,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -68,31 +213,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyDefinition') + + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +241,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -128,24 +266,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,6 +288,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -178,26 +310,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +333,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -224,8 +349,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -233,36 +360,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,6 +402,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py index 4bd1fca2c76e9..bf11ad96447bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json index 3f8fa2f9ef280..eac4d542e9207 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py index 9618907d38b26..814780607e858 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_policy_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2016_04_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2016_04_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2016_04_01.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py index 2020af54e225b..7a4aa0a943d40 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py index 0b0ff17f1c958..b8100f4b7e31e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2016_04_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2016_04_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2016_04_01.aio.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_assignments_operations.py index 01cf1f8dfb6a5..1b3f145be7a6e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,26 +69,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,8 +92,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -126,31 +125,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +153,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -188,26 +180,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -221,8 +203,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -236,8 +221,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -245,37 +232,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,11 +276,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -324,8 +309,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -333,41 +320,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -385,11 +372,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -400,8 +389,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -409,36 +400,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -456,11 +442,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -487,25 +475,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -519,8 +497,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -552,30 +533,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -589,8 +560,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -617,25 +591,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -649,4 +613,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_definitions_operations.py index 5552f093393df..da10280c9d0dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -63,31 +69,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyDefinition') + + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -122,24 +121,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -152,6 +143,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -171,26 +164,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,8 +187,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -216,8 +202,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -225,36 +213,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,6 +255,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models.py index b588d470c3976..88b859f12faf7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models.py @@ -12,18 +12,18 @@ class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :param id: The ID of the policy assignment. - :type id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str """ _attribute_map = { @@ -39,6 +39,20 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the policy assignment. + :paramtype id: str + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) @@ -51,10 +65,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -66,6 +80,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -78,18 +98,18 @@ class PolicyDefinition(msrest.serialization.Model): :ivar id: The ID of the policy definition. :vartype id: str - :param name: The name of the policy definition. If you do not specify a value for name, the + :ivar name: The name of the policy definition. If you do not specify a value for name, the value is inferred from the name value in the request URI. - :type name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :vartype name: str + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any """ _validation = { @@ -109,6 +129,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the policy definition. If you do not specify a value for name, the + value is inferred from the name value in the request URI. + :paramtype name: str + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -121,10 +155,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -136,6 +170,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py index 9e4cbc48be97b..346e1c1fd5ec8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_models_py3.py @@ -16,18 +16,18 @@ class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :param id: The ID of the policy assignment. - :type id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str + :ivar id: The ID of the policy assignment. + :vartype id: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str """ _attribute_map = { @@ -50,6 +50,20 @@ def __init__( scope: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the policy assignment. + :paramtype id: str + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = id self.type = type @@ -62,10 +76,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -80,6 +94,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -92,18 +112,18 @@ class PolicyDefinition(msrest.serialization.Model): :ivar id: The ID of the policy definition. :vartype id: str - :param name: The name of the policy definition. If you do not specify a value for name, the + :ivar name: The name of the policy definition. If you do not specify a value for name, the value is inferred from the name value in the request URI. - :type name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :vartype name: str + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any """ _validation = { @@ -129,6 +149,20 @@ def __init__( policy_rule: Optional[Any] = None, **kwargs ): + """ + :keyword name: The name of the policy definition. If you do not specify a value for name, the + value is inferred from the name value in the request URI. + :paramtype name: str + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyType + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = name @@ -141,10 +175,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -159,6 +193,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py index 0e62b3fa1096c..b6d41257fadba 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_assignments_operations.py index 3ef87ffde852a..9f9ec5a6e70a0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -68,26 +403,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +426,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -132,31 +460,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +488,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -195,26 +516,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -228,8 +539,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -244,8 +558,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -253,37 +569,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -301,11 +613,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -333,8 +647,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -342,41 +658,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -394,11 +710,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -410,8 +728,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -419,36 +739,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -466,11 +781,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -498,25 +815,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -530,8 +837,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -564,30 +874,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -601,8 +901,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -630,25 +933,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -662,4 +955,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_definitions_operations.py index 55da28e0c31e2..c13a238bde592 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/_policy_definitions_operations.py @@ -5,24 +5,168 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-04-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions') + 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] + 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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +189,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -68,31 +213,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyDefinition') + + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +241,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -128,24 +266,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,6 +288,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -178,26 +310,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +333,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -224,8 +349,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -233,36 +360,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-04-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,6 +402,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py index 90ba11964d978..1778f023a3ff0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json index e95ee0d406d2b..abac97553b705 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_definitions": "PolicyDefinitionsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py index eaf6282f3c8d3..d0ed710261706 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_policy_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyDefinitionsOperations -from .operations import PolicyAssignmentsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2016_12_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2016_12_01.operations.PolicyDefinitionsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2016_12_01.operations.PolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py index e76ba5a430391..a7be948bd0a41 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py index 11507ab89982d..1f66e49dcff9a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyDefinitionsOperations -from .operations import PolicyAssignmentsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2016_12_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2016_12_01.aio.operations.PolicyDefinitionsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2016_12_01.aio.operations.PolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_assignments_operations.py index b0de69c76118d..0c6eeb332fded 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,26 +69,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +94,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -128,31 +127,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -166,8 +155,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -190,26 +182,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +205,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -238,8 +223,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -247,37 +234,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -295,11 +278,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -326,8 +311,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -335,41 +322,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -387,11 +374,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -402,8 +391,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -411,36 +402,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -458,11 +444,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -489,25 +477,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -521,8 +499,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -554,30 +535,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -591,8 +562,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -619,25 +593,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -651,4 +615,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_definitions_operations.py index 1ca5d755f6814..1f8daad3fa72e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -63,31 +69,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -122,24 +121,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -152,6 +143,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -171,26 +164,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,8 +187,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -225,25 +211,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -257,8 +233,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -284,31 +263,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +291,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -346,24 +318,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -376,6 +340,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -398,26 +364,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -431,8 +387,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -440,8 +399,10 @@ def list( """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -449,34 +410,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -494,11 +450,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -506,8 +464,10 @@ def list_built_in( """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -515,30 +475,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,11 +513,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -571,8 +530,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -580,34 +541,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -625,6 +581,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models.py index d52de85cc82b1..a0a9fec2ed819 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models.py @@ -16,20 +16,20 @@ class PolicyAssignment(msrest.serialization.Model): :ivar id: The ID of the policy assignment. :vartype id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str """ _validation = { @@ -51,6 +51,22 @@ def __init__( self, **kwargs ): + """ + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = kwargs.get('type', None) @@ -65,10 +81,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -80,6 +96,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -94,22 +116,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype id: str :ivar name: The name of the policy definition. :vartype name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -133,6 +155,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -148,10 +188,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -163,6 +203,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py index b88e39b363698..2341f447eb8b6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_models_py3.py @@ -20,20 +20,20 @@ class PolicyAssignment(msrest.serialization.Model): :ivar id: The ID of the policy assignment. :vartype id: str - :param type: The type of the policy assignment. - :type type: str - :param name: The name of the policy assignment. - :type name: str - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str + :ivar type: The type of the policy assignment. + :vartype type: str + :ivar name: The name of the policy assignment. + :vartype name: str + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str """ _validation = { @@ -63,6 +63,22 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword type: The type of the policy assignment. + :paramtype type: str + :keyword name: The name of the policy assignment. + :paramtype name: str + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = type @@ -77,10 +93,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -95,6 +111,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -109,22 +131,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype id: str :ivar name: The name of the policy definition. :vartype name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -156,6 +178,24 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -171,10 +211,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -189,6 +229,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py index b6c6e85bd587a..2acd4055af049 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy definition mode. Possible values are NotSpecified, Indexed, and All. """ @@ -34,7 +19,7 @@ class PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_assignments_operations.py index d3a76b250fb1b..a28fcb9a56cc9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -68,26 +403,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,8 +428,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -134,31 +462,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -172,8 +490,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -197,26 +518,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -230,8 +541,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -246,8 +560,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -255,37 +571,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -303,11 +615,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -335,8 +649,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -344,41 +660,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -396,11 +712,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -412,8 +730,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -421,36 +741,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -468,11 +783,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -500,25 +817,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -532,8 +839,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -566,30 +876,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -603,8 +903,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -632,25 +935,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -664,4 +957,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_definitions_operations.py index f32fff4d2fb39..0c9f58b77efbf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -68,31 +399,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +427,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -128,24 +452,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,6 +474,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -178,26 +496,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +519,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -233,25 +544,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -265,8 +566,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -293,31 +597,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +625,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -356,24 +653,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,6 +675,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -409,26 +700,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,8 +723,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -452,8 +736,10 @@ def list( """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -461,34 +747,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -506,11 +787,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -519,8 +802,10 @@ def list_built_in( """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -528,30 +813,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -569,11 +851,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -585,8 +869,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -594,34 +880,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -639,6 +920,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py index d9235f9db71a6..3685c0e83a437 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +67,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json index 73d7b51e62ac1..a0fb50127c93c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py index d4427fa31932e..a3b9eaa66ca9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyAssignmentsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicySetDefinitionsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py index cd61c80f5dd79..71841d791aa5d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py index d6c0b8807f347..63cc67623aee0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicyAssignmentsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicySetDefinitionsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations.PolicyDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_assignments_operations.py index ab41d880dfddb..d628d8acc4b44 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,32 +69,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -99,8 +95,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -129,37 +128,27 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -168,8 +157,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -192,32 +184,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -226,8 +208,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -241,8 +226,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -250,37 +237,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,17 +276,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -330,8 +315,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -339,41 +326,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -386,17 +373,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,8 +396,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -416,36 +407,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -458,17 +444,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -495,31 +483,21 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -528,8 +506,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -561,36 +542,26 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -599,8 +570,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -627,31 +601,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -660,4 +624,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_definitions_operations.py index 3f2f805d72769..8686e73cf39ad 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -63,31 +69,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -122,24 +121,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -152,6 +143,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -171,26 +164,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,8 +187,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -225,25 +211,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -257,8 +233,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -284,31 +263,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +291,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -346,24 +318,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -376,6 +340,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -398,26 +364,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -431,8 +387,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -440,8 +399,10 @@ def list( """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -449,34 +410,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -494,11 +450,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -506,8 +464,10 @@ def list_built_in( """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -515,30 +475,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,11 +513,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -571,8 +530,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -580,34 +541,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -625,6 +581,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_set_definitions_operations.py index f0755eac4c950..ac9c8508a4705 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -63,37 +69,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -106,8 +102,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -127,32 +126,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -160,6 +149,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -179,32 +170,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -213,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -234,31 +218,21 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -267,8 +241,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -276,8 +253,10 @@ def list( """Gets all the policy set definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -285,34 +264,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,17 +299,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -343,8 +319,10 @@ def list_built_in( """Gets all the built in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -352,30 +330,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -388,17 +363,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -424,37 +401,27 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -467,8 +434,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -491,32 +461,22 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -524,6 +484,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -546,32 +508,22 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -580,8 +532,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -592,8 +547,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -601,34 +558,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -641,12 +593,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models.py index 2ce6f3740a69d..2b30cfe24aeaf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models.py @@ -13,12 +13,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates ARM is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -31,6 +31,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -48,22 +56,22 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. - :type sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :ivar sku: The policy sku. + :vartype sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -90,6 +98,24 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. + :paramtype sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -107,10 +133,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -122,6 +148,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -136,22 +168,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype id: str :ivar name: The name of the policy definition. :vartype name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -175,6 +207,25 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -190,10 +241,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -205,6 +256,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -213,10 +270,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -228,6 +285,12 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) @@ -244,20 +307,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] """ @@ -283,6 +346,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -298,10 +379,11 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -313,6 +395,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -323,10 +412,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -342,6 +431,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py index a846efcf06371..010494fc5a6b9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates ARM is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -56,22 +64,22 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. - :type sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :ivar sku: The policy sku. + :vartype sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -107,6 +115,24 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword sku: The policy sku. + :paramtype sku: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -124,10 +150,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -142,6 +168,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -156,22 +188,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype id: str :ivar name: The name of the policy definition. :vartype name: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -203,6 +235,25 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -218,10 +269,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -236,6 +287,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -244,10 +301,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -262,6 +319,12 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -278,20 +341,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] """ @@ -324,6 +387,24 @@ def __init__( policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or + ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -339,10 +420,11 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -357,6 +439,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: + list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -367,10 +456,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -389,6 +478,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py index b6c6e85bd587a..2acd4055af049 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy definition mode. Possible values are NotSpecified, Indexed, and All. """ @@ -34,7 +19,7 @@ class PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_assignments_operations.py index b43861be00889..741b3c2bb1cb1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -68,32 +403,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -104,8 +429,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -135,37 +463,27 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -174,8 +492,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -199,32 +520,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -233,8 +544,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -249,8 +563,10 @@ def list_for_resource_group( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -258,37 +574,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -301,17 +613,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -339,8 +653,10 @@ def list_for_resource( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -348,41 +664,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -395,17 +711,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,8 +735,10 @@ def list( :param filter: The filter to apply on the operation. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -426,36 +746,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -468,17 +783,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -506,31 +823,21 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -539,8 +846,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -573,36 +883,26 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -611,8 +911,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -640,31 +943,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -673,4 +966,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_definitions_operations.py index de7afdbc15385..841922a7c17f8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-12-01" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -68,31 +399,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +427,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -128,24 +452,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,6 +474,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -178,26 +496,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +519,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -233,25 +544,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -265,8 +566,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -293,31 +597,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +625,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -356,24 +653,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -386,6 +675,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -409,26 +700,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,8 +723,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -452,8 +736,10 @@ def list( """Gets all the policy definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -461,34 +747,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -506,11 +787,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -519,8 +802,10 @@ def list_built_in( """Gets all the built in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -528,30 +813,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -569,11 +851,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -585,8 +869,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -594,34 +880,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-12-01" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -639,6 +920,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_set_definitions_operations.py index b01a86ace0e3d..0968a17034ed7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-06-01-preview" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -68,37 +411,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -111,8 +444,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -133,32 +469,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -166,6 +492,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -186,32 +514,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -220,8 +538,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -242,31 +563,21 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -275,8 +586,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -285,8 +599,10 @@ def list( """Gets all the policy set definitions for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -294,34 +610,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -334,17 +645,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -353,8 +666,10 @@ def list_built_in( """Gets all the built in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -362,30 +677,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -398,17 +710,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -435,37 +749,27 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -478,8 +782,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -503,32 +810,22 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -536,6 +833,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -559,32 +858,22 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -593,8 +882,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -606,8 +898,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -615,34 +909,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-06-01-preview" - accept = "application/json, text/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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -655,12 +944,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py index da986422198ed..011ac2fe252e0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json index bcc49c7561e9a..a7c7220448738 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py index bb63e6f949530..c5f0b3406d006 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2018_03_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2018_03_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2018_03_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2018_03_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2018_03_01.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py index efd8fba7ea8dc..0158396cd59ed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py index 817a8f3c27646..e00197743c59c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2018_03_01.aio.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_assignments_operations.py index f38b7b785ef51..e6b1d64ec3e16 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,32 +77,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +103,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -142,37 +141,27 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -181,8 +170,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -212,32 +204,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -246,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -273,8 +258,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -282,37 +269,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,17 +308,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -387,8 +372,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -396,41 +383,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,17 +430,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -476,8 +465,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -485,36 +476,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -527,17 +513,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -566,31 +554,21 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -601,8 +579,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -637,36 +618,26 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -675,8 +646,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -706,31 +680,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -739,4 +703,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_definitions_operations.py index 7dae0843da267..36efe797365f6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,24 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -157,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -178,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -234,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -296,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -334,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -360,24 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -390,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -415,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -448,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -459,8 +418,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -468,34 +429,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -513,11 +469,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -527,8 +485,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -536,30 +496,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -577,11 +534,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -594,8 +553,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -603,34 +564,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,6 +604,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_set_definitions_operations.py index cd114a495b418..6e35a7e245d03 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,37 +72,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -109,8 +105,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -132,32 +131,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -165,6 +154,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -187,32 +178,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -221,8 +202,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -244,31 +228,21 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -277,8 +251,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -288,8 +265,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -297,34 +276,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,17 +311,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -357,8 +333,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -366,30 +344,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -402,17 +377,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -441,37 +418,27 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -484,8 +451,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -511,32 +481,22 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -544,6 +504,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -569,32 +531,22 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -603,8 +555,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -618,8 +573,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -627,34 +584,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -667,12 +619,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models.py index 84a5e6886a471..e5d128050103c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models.py @@ -13,12 +13,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -31,6 +31,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -48,23 +56,23 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -91,6 +99,25 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -108,10 +135,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -123,6 +150,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -139,22 +172,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -180,6 +213,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -196,10 +247,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -211,6 +262,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -219,10 +276,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -234,6 +291,12 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) @@ -250,20 +313,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] """ @@ -289,6 +352,23 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -304,10 +384,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -319,6 +399,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -329,10 +415,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -348,6 +434,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py index 82c1ea315fe85..eb94b7b8062b8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -56,23 +64,23 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -108,6 +116,25 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySku + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -125,10 +152,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -143,6 +170,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -159,22 +192,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -208,6 +241,24 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -224,10 +275,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -242,6 +293,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -250,10 +307,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -268,6 +325,12 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -284,20 +347,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] """ @@ -330,6 +393,23 @@ def __init__( policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -345,10 +425,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -363,6 +443,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -373,10 +459,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -395,6 +481,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py index b6c6e85bd587a..2acd4055af049 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy definition mode. Possible values are NotSpecified, Indexed, and All. """ @@ -34,7 +19,7 @@ class PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_assignments_operations.py index 50ebeb0bf9ddd..aa2654079e678 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,32 +411,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -112,8 +437,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -148,37 +476,27 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -187,8 +505,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -219,32 +540,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -253,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -281,8 +595,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -290,37 +606,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,17 +645,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -396,8 +710,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -405,41 +721,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -452,17 +768,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -486,8 +804,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -495,36 +815,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -537,17 +852,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -577,31 +894,21 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -612,8 +919,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -649,36 +959,26 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -687,8 +987,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -719,31 +1022,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -752,4 +1045,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_definitions_operations.py index 24d8c8df91467..b76efb88375f8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +402,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +430,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,24 +457,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +479,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -185,26 +503,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +526,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -242,25 +553,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +575,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -305,31 +609,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -343,8 +637,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -370,24 +667,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,6 +689,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -426,26 +717,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -459,8 +740,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -471,8 +755,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -480,34 +766,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,11 +806,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -540,8 +823,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -549,30 +834,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +872,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -608,8 +892,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -617,34 +903,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -662,6 +943,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_set_definitions_operations.py index e7b819872056b..95ede7e2d8b82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,37 +414,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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,8 +447,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -138,32 +474,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -171,6 +497,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -194,32 +522,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -228,8 +546,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -252,31 +573,21 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -285,8 +596,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -297,8 +611,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -306,34 +622,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -346,17 +657,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -367,8 +680,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -376,30 +691,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,17 +724,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -452,37 +766,27 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -495,8 +799,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -523,32 +830,22 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -556,6 +853,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -582,32 +881,22 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -616,8 +905,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -632,8 +924,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -641,34 +935,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -681,12 +970,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py index 48ace5b219d79..243408357302f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json index cc5012455bf65..f336d3a0e8daf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py index 0ca0cc3646548..500fbeb437339 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2018_05_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2018_05_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2018_05_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2018_05_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2018_05_01.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py index cc3a68127e7b2..c2d32ca02b7ad 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py index a4cc6d2b7b15d..1dfef34017e32 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2018_05_01.aio.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_assignments_operations.py index 4f36d69fe2d4c..2462b7169dec4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,32 +77,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +103,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -142,37 +141,27 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -181,8 +170,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -212,32 +204,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -246,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -273,8 +258,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -282,37 +269,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,17 +308,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -387,8 +372,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -396,41 +383,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,17 +430,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -476,8 +465,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -485,36 +476,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -527,17 +513,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -566,31 +554,21 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -601,8 +579,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -637,36 +618,26 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -675,8 +646,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -706,31 +680,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -739,4 +703,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_definitions_operations.py index 641ba9a477846..944d1b6597be6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,24 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -157,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -178,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -234,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -296,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -334,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -360,24 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -390,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -415,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -448,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -459,8 +418,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -468,34 +429,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -513,11 +469,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -527,8 +485,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -536,30 +496,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -577,11 +534,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -594,8 +553,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -603,34 +564,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,6 +604,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_set_definitions_operations.py index 40965f0d9206d..74b40ba255861 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,37 +72,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -109,8 +105,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -132,32 +131,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -165,6 +154,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -187,32 +178,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -221,8 +202,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -244,31 +228,21 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -277,8 +251,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -288,8 +265,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -297,34 +276,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,17 +311,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -357,8 +333,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -366,30 +344,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -402,17 +377,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -441,37 +418,27 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -484,8 +451,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -511,32 +481,22 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -544,6 +504,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -569,32 +531,22 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -603,8 +555,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -618,8 +573,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -627,34 +584,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -667,12 +619,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models.py index f05b3d31fcd2d..30bc7250d7af6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models.py @@ -13,12 +13,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -31,6 +31,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -46,8 +54,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ _validation = { @@ -65,6 +73,10 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -82,28 +94,28 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -132,6 +144,30 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -151,10 +187,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -166,6 +202,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -182,22 +224,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -223,6 +265,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -239,10 +299,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -254,6 +314,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -262,10 +328,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -277,6 +343,12 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) @@ -293,20 +365,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] """ @@ -332,6 +404,23 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -347,10 +436,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -362,6 +451,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -372,10 +467,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -391,6 +486,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py index 6a870ebcec589..a95e2c50c393f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -54,8 +62,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ _validation = { @@ -75,6 +83,10 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -92,28 +104,28 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -153,6 +165,30 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2018_05_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -172,10 +208,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -190,6 +226,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -206,22 +248,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType - :param mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :ivar mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. Possible values include: "NotSpecified", "Indexed", "All". - :type mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -255,6 +297,24 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :keyword mode: The policy definition mode. Possible values are NotSpecified, Indexed, and All. + Possible values include: "NotSpecified", "Indexed", "All". + :paramtype mode: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -271,10 +331,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -289,6 +349,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -297,10 +363,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -315,6 +381,12 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -331,20 +403,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] """ @@ -377,6 +449,23 @@ def __init__( policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -392,10 +481,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -410,6 +499,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -420,10 +515,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -442,6 +537,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py index a93d927ab3bb2..cd821eee59b98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy definition mode. Possible values are NotSpecified, Indexed, and All. """ @@ -34,7 +19,7 @@ class PolicyMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDEXED = "Indexed" ALL = "All" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ @@ -42,7 +27,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_assignments_operations.py index 98700c2120697..ec427ce02c28e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,32 +411,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -112,8 +437,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -148,37 +476,27 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -187,8 +505,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -219,32 +540,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -253,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -281,8 +595,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -290,37 +606,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,17 +645,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -396,8 +710,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -405,41 +721,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -452,17 +768,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -486,8 +804,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -495,36 +815,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -537,17 +852,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -577,31 +894,21 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -612,8 +919,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -649,36 +959,26 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -687,8 +987,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -719,31 +1022,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -752,4 +1045,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_definitions_operations.py index 85795154d7760..e03fd0f8ae38f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +402,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +430,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,24 +457,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +479,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -185,26 +503,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +526,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -242,25 +553,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +575,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -305,31 +609,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -343,8 +637,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -370,24 +667,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,6 +689,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -426,26 +717,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -459,8 +740,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -471,8 +755,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -480,34 +766,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,11 +806,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -540,8 +823,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -549,30 +834,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +872,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -608,8 +892,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -617,34 +903,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -662,6 +943,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_set_definitions_operations.py index 95b7d3b08ddbe..f07db56e33b39 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,37 +414,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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,8 +447,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -138,32 +474,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -171,6 +497,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -194,32 +522,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -228,8 +546,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -252,31 +573,21 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -285,8 +596,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -297,8 +611,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -306,34 +622,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -346,17 +657,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -367,8 +680,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -376,30 +691,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,17 +724,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -452,37 +766,27 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -495,8 +799,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -523,32 +830,22 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -556,6 +853,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -582,32 +881,22 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -616,8 +905,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -632,8 +924,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -641,34 +935,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -681,12 +970,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py index 794723b171c2c..df380456d7a99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json index be657bbac3558..0d2388a31182b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py index 2254cf59e1f7b..566a922ee7b3b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_01_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_01_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_01_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_01_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_01_01.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py index 786cccecf0039..f3e9c17c7b223 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py index d4ea3607d75aa..349c0e5f4fbe8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_01_01.aio.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_assignments_operations.py index d4392d5938b5a..e124e6aaed088 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,32 +77,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +103,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -142,37 +141,27 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -181,8 +170,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -212,32 +204,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -246,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -273,8 +258,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -282,37 +269,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,17 +308,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -387,8 +372,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -396,41 +383,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,17 +430,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -476,8 +465,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -485,36 +476,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -527,17 +513,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -566,31 +554,21 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -601,8 +579,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -637,36 +618,26 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -675,8 +646,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -706,31 +680,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -739,4 +703,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_definitions_operations.py index 7a359b11febef..26e548167e455 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,24 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -157,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -178,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -234,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -296,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -334,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -360,24 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -390,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -415,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -448,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -459,8 +418,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -468,34 +429,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -513,11 +469,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -527,8 +485,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -536,30 +496,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -577,11 +534,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -594,8 +553,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -603,34 +564,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,6 +604,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_set_definitions_operations.py index 4dc6ccdf961b0..3edf8da838222 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,37 +72,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -109,8 +105,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -132,32 +131,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -165,6 +154,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -187,32 +178,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -221,8 +202,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -244,31 +228,21 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -277,8 +251,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -288,8 +265,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -297,34 +276,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,17 +311,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -357,8 +333,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -366,30 +344,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -402,17 +377,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -441,37 +418,27 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -484,8 +451,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -511,32 +481,22 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -544,6 +504,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -569,32 +531,22 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -603,8 +555,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -618,8 +573,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -627,34 +584,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -667,12 +619,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models.py index d65ebe1d88760..f2fe00cdcc5f6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models.py @@ -13,12 +13,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -31,6 +31,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -46,8 +54,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ _validation = { @@ -65,6 +73,10 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -82,28 +94,28 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -132,6 +144,30 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -151,10 +187,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -166,6 +202,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -182,22 +224,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -223,6 +265,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -239,10 +299,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -254,6 +314,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -262,10 +328,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -277,6 +343,12 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) @@ -293,20 +365,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] """ @@ -332,6 +404,23 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -347,10 +436,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -362,6 +451,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -372,10 +467,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -391,6 +486,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py index ba254bf17eb86..0eec5d730d790 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -54,8 +62,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ _validation = { @@ -75,6 +83,10 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -92,28 +104,28 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any """ _validation = { @@ -153,6 +165,30 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_01_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -172,10 +208,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -190,6 +226,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -206,22 +248,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -255,6 +297,24 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -271,10 +331,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -289,6 +349,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -297,10 +363,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -315,6 +381,12 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -331,20 +403,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] """ @@ -377,6 +449,23 @@ def __init__( policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -392,10 +481,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -410,6 +499,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -420,10 +515,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -442,6 +537,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py index 32f9bd2236399..4650214a26848 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ @@ -34,7 +19,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_assignments_operations.py index c30c2cbc4ca8d..6b3f748c08459 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,32 +411,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -112,8 +437,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -148,37 +476,27 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -187,8 +505,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -219,32 +540,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -253,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -281,8 +595,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -290,37 +606,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,17 +645,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -396,8 +710,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -405,41 +721,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -452,17 +768,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -486,8 +804,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -495,36 +815,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -537,17 +852,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -577,31 +894,21 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -612,8 +919,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -649,36 +959,26 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -687,8 +987,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -719,31 +1022,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -752,4 +1045,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_definitions_operations.py index 0e7fc13eff0b0..39297c9bc10f3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +402,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +430,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,24 +457,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +479,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -185,26 +503,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +526,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -242,25 +553,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +575,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -305,31 +609,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -343,8 +637,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -370,24 +667,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,6 +689,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -426,26 +717,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -459,8 +740,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -471,8 +755,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -480,34 +766,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,11 +806,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -540,8 +823,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -549,30 +834,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +872,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -608,8 +892,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -617,34 +903,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -662,6 +943,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_set_definitions_operations.py index 348e3a98c05f0..64dabca959bf0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,37 +414,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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,8 +447,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -138,32 +474,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -171,6 +497,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -194,32 +522,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -228,8 +546,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -252,31 +573,21 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -285,8 +596,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -297,8 +611,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -306,34 +622,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -346,17 +657,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -367,8 +680,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -376,30 +691,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,17 +724,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -452,37 +766,27 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -495,8 +799,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -523,32 +830,22 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -556,6 +853,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -582,32 +881,22 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -616,8 +905,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -632,8 +924,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -641,34 +935,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -681,12 +970,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py index 7e12c84f38b12..a9e4976e054e9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json index e6fa60072e0b9..1214991831c29 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py index a86c326ea0001..3a3858d1a13e7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_06_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_06_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_06_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_06_01.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py index b6cd316be8f45..13ca78b7c01c2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py index e2ff40ae49db0..774f350eedcaf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_06_01.aio.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_assignments_operations.py index 2e973367bac1f..d30075dd462cc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,32 +77,22 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -107,8 +103,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -142,37 +141,27 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -181,8 +170,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -212,32 +204,22 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -246,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -273,8 +258,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -282,37 +269,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -325,17 +308,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -387,8 +372,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -396,41 +383,41 @@ def list_for_resource( 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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,17 +430,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -476,8 +465,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -485,36 +476,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -527,17 +513,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -566,31 +554,21 @@ async def delete_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.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -601,8 +579,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -637,36 +618,26 @@ async def create_by_id( 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_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -675,8 +646,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -706,31 +680,21 @@ 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 = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -739,4 +703,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_definitions_operations.py index ceb47eb0102d9..b02516ec07df8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ 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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,24 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -157,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -178,26 +171,16 @@ 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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -234,25 +220,15 @@ async def get_built_in( 401: 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_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -296,31 +275,21 @@ async def create_or_update_at_management_group( 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -334,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -360,24 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -390,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -415,26 +381,16 @@ async def get_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -448,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -459,8 +418,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -468,34 +429,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -513,11 +469,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -527,8 +485,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -536,30 +496,27 @@ def list_built_in( 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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -577,11 +534,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -594,8 +553,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -603,34 +564,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,6 +604,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_set_definitions_operations.py index 662da99234100..41fcd4837fc4a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,37 +72,27 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -109,8 +105,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -132,32 +131,22 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -165,6 +154,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -187,32 +178,22 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -221,8 +202,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -244,31 +228,21 @@ async def get_built_in( 401: 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_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -277,8 +251,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -288,8 +265,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -297,34 +276,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,17 +311,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -357,8 +333,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -366,30 +344,27 @@ def list_built_in( 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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -402,17 +377,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -441,37 +418,27 @@ async def create_or_update_at_management_group( 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -484,8 +451,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -511,32 +481,22 @@ async def delete_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -544,6 +504,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -569,32 +531,22 @@ async def get_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -603,8 +555,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -618,8 +573,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -627,34 +584,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -667,12 +619,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py index 291aaf61dfa37..ce769116a78f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models.py @@ -13,12 +13,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -31,6 +31,14 @@ def __init__( self, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) @@ -46,8 +54,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ _validation = { @@ -65,6 +73,10 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -82,31 +94,32 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode """ _validation = { @@ -136,6 +149,34 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -156,10 +197,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -171,6 +212,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -187,22 +234,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -228,6 +275,24 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -244,10 +309,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -259,6 +324,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -267,10 +338,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -282,6 +353,12 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) @@ -298,20 +375,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] """ @@ -337,6 +414,23 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -352,10 +446,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -367,6 +461,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -377,10 +477,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -396,6 +496,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py index 967a978184be4..f645863400817 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_models_py3.py @@ -17,12 +17,12 @@ class ErrorResponse(msrest.serialization.Model): """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - :param http_status: Http status code. - :type http_status: str - :param error_code: Error code. - :type error_code: str - :param error_message: Error message indicating why the operation failed. - :type error_message: str + :ivar http_status: Http status code. + :vartype http_status: str + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str """ _attribute_map = { @@ -39,6 +39,14 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword http_status: Http status code. + :paramtype http_status: str + :keyword error_code: Error code. + :paramtype error_code: str + :keyword error_message: Error message indicating why the operation failed. + :paramtype error_message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code @@ -54,8 +62,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ _validation = { @@ -75,6 +83,10 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -92,31 +104,32 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode """ _validation = { @@ -158,6 +171,34 @@ def __init__( enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_06_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_06_01.models.EnforcementMode + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -178,10 +219,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -196,6 +237,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -212,22 +259,22 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. - :type metadata: any - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. + :vartype metadata: any + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _validation = { @@ -261,6 +308,24 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. + :paramtype metadata: any + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -277,10 +342,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -295,6 +360,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -303,10 +374,10 @@ def __init__( class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set definition. - :type policy_definition_id: str - :param parameters: Required if a parameter is used in policy rule. - :type parameters: any + :ivar policy_definition_id: The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: Required if a parameter is used in policy rule. + :vartype parameters: any """ _attribute_map = { @@ -321,6 +392,12 @@ def __init__( parameters: Optional[Any] = None, **kwargs ): + """ + :keyword policy_definition_id: The ID of the policy definition or policy set definition. + :paramtype policy_definition_id: str + :keyword parameters: Required if a parameter is used in policy rule. + :paramtype parameters: any + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -337,20 +414,20 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: any - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :vartype parameters: any + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] """ @@ -383,6 +460,23 @@ def __init__( policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + and Custom. Possible values include: "NotSpecified", "BuiltIn", "Custom". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: any + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -398,10 +492,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -416,6 +510,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -426,10 +526,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -448,6 +548,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py index 727103c25ed65..6917546afc103 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. """ @@ -35,7 +20,7 @@ class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. """ @@ -43,7 +28,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BUILT_IN = "BuiltIn" CUSTOM = "Custom" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py index b49f157a2ef7b..ba749e6c9e720 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_assignments_operations.py @@ -5,24 +5,358 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +379,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,32 +411,22 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -112,8 +437,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -148,37 +476,27 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -187,8 +505,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -219,32 +540,22 @@ 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -253,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -281,8 +595,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -290,37 +606,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,17 +645,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -396,8 +710,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -405,41 +721,41 @@ def list_for_resource( 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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -452,17 +768,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -486,8 +804,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -495,36 +815,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -537,17 +852,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -577,31 +894,21 @@ def delete_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.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -612,8 +919,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -649,36 +959,26 @@ def create_by_id( 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_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -687,8 +987,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -719,31 +1022,21 @@ 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 = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyAssignment', pipeline_response) @@ -752,4 +1045,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_definitions_operations.py index 8813c23be84dc..76dec6aeeeac5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_definitions_operations.py @@ -5,24 +5,354 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +375,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +402,21 @@ 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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +430,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,24 +457,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +479,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -185,26 +503,16 @@ 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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +526,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -242,25 +553,15 @@ def get_built_in( 401: 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_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +575,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -305,31 +609,21 @@ def create_or_update_at_management_group( 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -343,8 +637,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -370,24 +667,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -400,6 +689,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -426,26 +717,16 @@ def get_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -459,8 +740,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -471,8 +755,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -480,34 +766,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -525,11 +806,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -540,8 +823,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -549,30 +834,27 @@ def list_built_in( 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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +872,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -608,8 +892,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -617,34 +903,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -662,6 +943,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py index 863ca9dcfc5ce..c4aa9c1dfcc28 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,37 +414,27 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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,8 +447,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -138,32 +474,22 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -171,6 +497,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -194,32 +522,22 @@ 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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -228,8 +546,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -252,31 +573,21 @@ def get_built_in( 401: 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_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -285,8 +596,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -297,8 +611,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -306,34 +622,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -346,17 +657,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -367,8 +680,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -376,30 +691,27 @@ def list_built_in( 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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,17 +724,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_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_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -452,37 +766,27 @@ def create_or_update_at_management_group( 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_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: @@ -495,8 +799,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -523,32 +830,22 @@ def delete_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -556,6 +853,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -582,32 +881,22 @@ def get_at_management_group( 401: 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_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicySetDefinition', pipeline_response) @@ -616,8 +905,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -632,8 +924,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -641,34 +935,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -681,12 +970,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py index 3a2ae9470f0da..f61e7f3c96b45 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json index 36d635c37ab0c..c9507c486e199 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "policy_assignments": "PolicyAssignmentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py index 89d052b27985f..578d2e395f2bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_policy_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_09_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_09_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py index 4b7438aecd3d1..3eb2eee82e3db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py index 706da20988d51..fd4a3aa23c641 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client.py @@ -6,79 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2019_09_01.aio.operations.PolicySetDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_assignments_operations.py index 557bf3dfa85f2..8c923a0649563 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_management_group_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,26 +77,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +102,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -141,31 +140,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +168,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -210,26 +202,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +225,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -270,8 +255,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -279,37 +266,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -327,11 +310,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -383,8 +368,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -392,41 +379,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -444,11 +431,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id: str, @@ -471,8 +460,10 @@ def list_for_management_group( management group scope. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -480,35 +471,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -526,11 +513,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -553,8 +542,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -562,36 +553,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -609,11 +595,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -642,25 +630,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -676,8 +654,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -712,30 +693,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -749,8 +720,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -780,25 +754,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -812,4 +776,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_definitions_operations.py index 9672916190e2a..5045f27fc8fd5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,26 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -180,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -236,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -268,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -298,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -336,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -362,26 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -394,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -419,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -452,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -463,8 +418,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -472,34 +429,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -517,11 +469,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -531,8 +485,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -540,30 +496,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -581,11 +534,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -598,8 +553,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -607,34 +564,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -652,6 +604,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_set_definitions_operations.py index c397cc358cb17..9f56a31a05b17 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -131,26 +130,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +152,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -185,26 +176,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +199,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -241,25 +225,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,8 +247,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -284,8 +261,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -293,34 +272,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -338,11 +312,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs: Any @@ -352,8 +328,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -361,30 +339,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -402,11 +377,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -435,31 +412,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -477,8 +444,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -504,26 +474,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -536,6 +496,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -561,26 +523,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -594,8 +546,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -609,8 +564,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -618,34 +575,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -663,6 +615,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py index 3fa6968859727..50a6898664928 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models.py @@ -34,6 +34,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -77,6 +79,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -94,9 +98,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system assigned + :ivar type: The identity type. This is the only required field when adding a system assigned identity to a resource. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType """ _validation = { @@ -114,6 +118,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system assigned + identity to a resource. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -123,15 +132,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata """ @@ -146,6 +155,18 @@ def __init__( self, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.allowed_values = kwargs.get('allowed_values', None) @@ -156,13 +177,13 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str """ _attribute_map = { @@ -175,6 +196,15 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.display_name = kwargs.get('display_name', None) @@ -184,8 +214,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -196,6 +226,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -211,34 +245,35 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode """ _validation = { @@ -268,6 +303,37 @@ def __init__( self, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -288,10 +354,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -303,6 +369,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -319,24 +391,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] """ @@ -363,6 +435,27 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -381,17 +474,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -410,6 +503,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = kwargs['name'] self.display_name = kwargs.get('display_name', None) @@ -421,10 +527,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -436,6 +542,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -446,18 +558,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -475,6 +586,20 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs['policy_definition_id'] self.parameters = kwargs.get('parameters', None) @@ -493,26 +618,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] """ @@ -539,6 +664,29 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -555,10 +703,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -570,6 +718,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -580,10 +734,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -599,6 +753,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = kwargs['name'] self.tier = kwargs.get('tier', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py index 4844d274e0a42..c65435bf8a869 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_models_py3.py @@ -38,6 +38,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -81,6 +83,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -98,9 +102,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system assigned + :ivar type: The identity type. This is the only required field when adding a system assigned identity to a resource. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType """ _validation = { @@ -120,6 +124,11 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system assigned + identity to a resource. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -129,15 +138,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata """ @@ -157,6 +166,18 @@ def __init__( metadata: Optional["ParameterDefinitionsValueMetadata"] = None, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = type self.allowed_values = allowed_values @@ -167,13 +188,13 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str """ _attribute_map = { @@ -190,6 +211,15 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name @@ -199,8 +229,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -213,6 +243,10 @@ def __init__( value: Optional[Any] = None, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = value @@ -228,34 +262,35 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param sku: The policy sku. This property is optional, obsolete, and will be ignored. - :type sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar sku: The policy sku. This property is optional, obsolete, and will be ignored. + :vartype sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str - :param scope: The scope for the policy assignment. - :type scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :vartype policy_definition_id: str + :ivar scope: The scope for the policy assignment. + :vartype scope: str + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode """ _validation = { @@ -297,6 +332,37 @@ def __init__( enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, **kwargs ): + """ + :keyword sku: The policy sku. This property is optional, obsolete, and will be ignored. + :paramtype sku: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySku + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2019_09_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword scope: The scope for the policy assignment. + :paramtype scope: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2019_09_01.models.EnforcementMode + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -317,10 +383,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -335,6 +401,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -351,24 +423,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] """ @@ -403,6 +475,27 @@ def __init__( parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -421,17 +514,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -456,6 +549,19 @@ def __init__( additional_metadata_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -467,10 +573,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -485,6 +591,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -495,18 +607,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -529,6 +640,20 @@ def __init__( group_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -547,26 +672,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] """ @@ -601,6 +726,29 @@ def __init__( policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -617,10 +765,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -635,6 +783,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -645,10 +799,10 @@ class PolicySku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the policy sku. Possible values are A0 and A1. - :type name: str - :param tier: The policy sku tier. Possible values are Free and Standard. - :type tier: str + :ivar name: Required. The name of the policy sku. Possible values are A0 and A1. + :vartype name: str + :ivar tier: The policy sku tier. Possible values are Free and Standard. + :vartype tier: str """ _validation = { @@ -667,6 +821,12 @@ def __init__( tier: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the policy sku. Possible values are A0 and A1. + :paramtype name: str + :keyword tier: The policy sku tier. Possible values are Free and Standard. + :paramtype tier: str + """ super(PolicySku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py index eb3da766a6479..74e077ddc5f12 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. """ @@ -35,7 +20,7 @@ class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The data type of the parameter. """ @@ -47,7 +32,7 @@ class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. """ @@ -56,7 +41,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. This is the only required field when adding a system assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py index 88daff7794b97..e5fd91d04ffe3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_assignments_operations.py @@ -5,24 +5,393 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_list_for_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter') # type: str + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + 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_delete_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +414,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,26 +446,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,8 +471,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -147,31 +510,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +538,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -217,26 +573,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -250,8 +596,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -278,8 +627,10 @@ def list_for_resource_group( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -287,37 +638,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -335,11 +682,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -392,8 +741,10 @@ def list_for_resource( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -401,41 +752,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,11 +804,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id, # type: str @@ -481,8 +834,10 @@ def list_for_management_group( management group scope. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -490,35 +845,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -536,11 +887,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -564,8 +917,10 @@ def list( or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -573,36 +928,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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] - 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_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -620,11 +970,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -654,25 +1006,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -688,8 +1030,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -725,30 +1070,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,8 +1097,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -794,25 +1132,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -826,4 +1154,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py index db6ad67c34ba1..1586fa96503c8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +414,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +442,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,26 +469,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,6 +491,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -187,26 +515,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -220,8 +538,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -244,25 +565,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,8 +587,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -307,31 +621,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -345,8 +649,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -372,26 +679,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,6 +701,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -430,26 +729,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -463,8 +752,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -475,8 +767,10 @@ def list( This operation retrieves a list of all the policy definitions in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -484,34 +778,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -529,11 +818,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -544,8 +835,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -553,30 +846,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -594,11 +884,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -612,8 +904,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -621,34 +915,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -666,6 +955,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py index 67a0021a12409..b7be6b63f5cf2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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 + ) + + +def build_list_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +387,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,31 +414,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,8 +446,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -137,26 +473,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,6 +495,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -192,26 +520,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,8 +543,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -249,25 +570,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,8 +592,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -293,8 +607,10 @@ def list( This operation retrieves a list of all the policy set definitions in the given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -302,34 +618,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -347,11 +658,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, **kwargs # type: Any @@ -362,8 +675,10 @@ def list_built_in( This operation retrieves a list of all the built-in policy set definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -371,30 +686,27 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_built_in.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_built_in_request( + template_url=self.list_built_in.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_built_in_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -412,11 +724,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -446,31 +760,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -488,8 +792,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -516,26 +823,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -548,6 +845,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -574,26 +873,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -607,8 +896,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -623,8 +915,10 @@ def list_by_management_group( :param management_group_id: The ID of the management group. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -632,34 +926,29 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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_management_group_request( + management_group_id=management_group_id, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -677,6 +966,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py index d9235f9db71a6..3685c0e83a437 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +67,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json index 8bf9401120c49..6652516f13912 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "data_policy_manifests": "DataPolicyManifestsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py index b25c7ae55e2ec..438d2d6785223 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_policy_client.py @@ -6,93 +6,97 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyExemptionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: azure.mgmt.resource.policy.v2020_09_01.operations.DataPolicyManifestsOperations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.v2020_09_01.operations.DataPolicyManifestsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2020_09_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2020_09_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2020_09_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2020_09_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2020_09_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2020_09_01.operations.PolicySetDefinitionsOperations :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.v2020_09_01.operations.PolicyExemptionsOperations + :vartype policy_exemptions: + azure.mgmt.resource.policy.v2020_09_01.operations.PolicyExemptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py index cd61c80f5dd79..71841d791aa5d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py index cd3907c09ae08..0080a75755c5f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/_policy_client.py @@ -6,89 +6,93 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyExemptionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: azure.mgmt.resource.policy.v2020_09_01.aio.operations.DataPolicyManifestsOperations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.v2020_09_01.aio.operations.DataPolicyManifestsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicySetDefinitionsOperations :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyExemptionsOperations + :vartype policy_exemptions: + azure.mgmt.resource.policy.v2020_09_01.aio.operations.PolicyExemptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_data_policy_manifests_operations.py index 28f9ce4fc020c..34bf486b9d4c5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_data_policy_manifests_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_data_policy_manifests_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._data_policy_manifests_operations import build_get_by_policy_mode_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_policy_mode( self, policy_mode: str, @@ -62,25 +68,15 @@ async def get_by_policy_mode( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_policy_mode.metadata['url'] # type: ignore - path_format_arguments = { - 'policyMode': self._serialize.url("policy_mode", policy_mode, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_policy_mode_request( + policy_mode=policy_mode, + template_url=self.get_by_policy_mode.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,8 +90,11 @@ async def get_by_policy_mode( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -115,8 +114,10 @@ def list( namespace matching the provided value. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] + :return: An iterator like instance of either DataPolicyManifestListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] @@ -124,32 +125,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + 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('DataPolicyManifestListResult', pipeline_response) + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,6 +165,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_assignments_operations.py index 3ebe2e2f09211..08f0735a154b1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_management_group_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,26 +77,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +102,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -141,31 +140,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +168,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -210,26 +202,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +225,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -282,8 +267,10 @@ def list_for_resource_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -291,39 +278,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -341,11 +324,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -408,8 +393,10 @@ def list_for_resource( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -417,43 +404,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -471,11 +458,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id: str, @@ -509,8 +498,10 @@ def list_for_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -518,38 +509,33 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -567,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -605,8 +593,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -614,38 +604,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -663,11 +648,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -696,25 +683,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -730,8 +707,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -766,30 +746,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -803,8 +773,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -834,25 +807,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -866,4 +829,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_definitions_operations.py index 5ce1f9bac1264..848921d654093 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,26 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -180,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -236,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -268,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -298,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -336,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -362,26 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -394,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -419,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -452,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -486,8 +441,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -495,38 +452,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -544,11 +496,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter: Optional[str] = None, @@ -576,8 +530,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -585,34 +541,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -630,11 +583,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -671,8 +626,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -680,38 +637,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,6 +681,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_exemptions_operations.py index cfbe58839bb99..7b6e3cd0b0754 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_exemptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_exemptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_exemptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_for_management_group_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,26 +77,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,6 +99,8 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -137,31 +135,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyExemption') + + request = build_create_or_update_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyExemption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +167,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -210,26 +201,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +224,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -273,8 +257,10 @@ def list( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -282,36 +268,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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, + filter=filter, + 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, + 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('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -329,11 +310,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -365,8 +348,10 @@ def list_for_resource_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -374,37 +359,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource_group.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\._\(\)]+$'), - } - 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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,11 +403,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -484,8 +467,10 @@ def list_for_resource( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -493,41 +478,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource.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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -545,11 +530,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id: str, @@ -580,8 +567,10 @@ def list_for_management_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -589,36 +578,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -636,6 +620,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_set_definitions_operations.py index dcc59547af642..70a180ccb113b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -131,26 +130,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +152,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -185,26 +176,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +199,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -241,25 +225,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,8 +247,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -307,8 +284,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -316,38 +295,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -365,11 +339,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter: Optional[str] = None, @@ -395,8 +371,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -404,34 +382,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -449,11 +424,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -482,31 +459,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -524,8 +491,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -551,26 +521,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -583,6 +543,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -608,26 +570,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -641,8 +593,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -679,8 +634,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -688,38 +645,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -737,6 +689,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models.py index fc891799e0a73..2198c311cb9d4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -121,6 +142,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -129,12 +152,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType """ _attribute_map = { @@ -147,6 +170,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -156,10 +187,10 @@ def __init__( class DataEffect(msrest.serialization.Model): """The data effect definition. - :param name: The data effect name. - :type name: str - :param details_schema: The data effect details schema. - :type details_schema: any + :ivar name: The data effect name. + :vartype name: str + :ivar details_schema: The data effect details schema. + :vartype details_schema: any """ _attribute_map = { @@ -171,6 +202,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The data effect name. + :paramtype name: str + :keyword details_schema: The data effect details schema. + :paramtype details_schema: any + """ super(DataEffect, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.details_schema = kwargs.get('details_schema', None) @@ -179,18 +216,18 @@ def __init__( class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """The custom resource function definition. - :param name: The function name as it will appear in the policy rule. eg - 'vault'. - :type name: str - :param fully_qualified_resource_type: The fully qualified control plane resource type that this + :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. + :vartype name: str + :ivar fully_qualified_resource_type: The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - :type fully_qualified_resource_type: str - :param default_properties: The top-level properties that can be selected on the function's + :vartype fully_qualified_resource_type: str + :ivar default_properties: The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and vault().location are supported. - :type default_properties: list[str] - :param allow_custom_properties: A value indicating whether the custom properties within the + :vartype default_properties: list[str] + :ivar allow_custom_properties: A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified in the policy rule eg - vault('2019-06-01'). - :type allow_custom_properties: bool + :vartype allow_custom_properties: bool """ _attribute_map = { @@ -204,6 +241,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The function name as it will appear in the policy rule. eg - 'vault'. + :paramtype name: str + :keyword fully_qualified_resource_type: The fully qualified control plane resource type that + this function represents. eg - 'Microsoft.KeyVault/vaults'. + :paramtype fully_qualified_resource_type: str + :keyword default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :paramtype default_properties: list[str] + :keyword allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :paramtype allow_custom_properties: bool + """ super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.fully_qualified_resource_type = kwargs.get('fully_qualified_resource_type', None) @@ -222,24 +273,24 @@ class DataPolicyManifest(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). :vartype type: str - :param namespaces: The list of namespaces for the data policy manifest. - :type namespaces: list[str] - :param policy_mode: The policy mode of the data policy manifest. - :type policy_mode: str - :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + :ivar namespaces: The list of namespaces for the data policy manifest. + :vartype namespaces: list[str] + :ivar policy_mode: The policy mode of the data policy manifest. + :vartype policy_mode: str + :ivar is_built_in_only: A value indicating whether policy mode is allowed only in built-in definitions. - :type is_built_in_only: bool - :param resource_type_aliases: An array of resource type aliases. - :type resource_type_aliases: + :vartype is_built_in_only: bool + :ivar resource_type_aliases: An array of resource type aliases. + :vartype resource_type_aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.ResourceTypeAliases] - :param effects: The effect definition. - :type effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] - :param field_values: The non-alias field accessor values that can be used in the policy rule. - :type field_values: list[str] - :param standard: The standard resource functions (subscription and/or resourceGroup). - :type standard: list[str] - :param custom: An array of data manifest custom resource definition. - :type custom: + :ivar effects: The effect definition. + :vartype effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] + :ivar field_values: The non-alias field accessor values that can be used in the policy rule. + :vartype field_values: list[str] + :ivar standard: The standard resource functions (subscription and/or resourceGroup). + :vartype standard: list[str] + :ivar custom: An array of data manifest custom resource definition. + :vartype custom: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataManifestCustomResourceFunctionDefinition] """ @@ -267,6 +318,27 @@ def __init__( self, **kwargs ): + """ + :keyword namespaces: The list of namespaces for the data policy manifest. + :paramtype namespaces: list[str] + :keyword policy_mode: The policy mode of the data policy manifest. + :paramtype policy_mode: str + :keyword is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :paramtype is_built_in_only: bool + :keyword resource_type_aliases: An array of resource type aliases. + :paramtype resource_type_aliases: + list[~azure.mgmt.resource.policy.v2020_09_01.models.ResourceTypeAliases] + :keyword effects: The effect definition. + :paramtype effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] + :keyword field_values: The non-alias field accessor values that can be used in the policy rule. + :paramtype field_values: list[str] + :keyword standard: The standard resource functions (subscription and/or resourceGroup). + :paramtype standard: list[str] + :keyword custom: An array of data manifest custom resource definition. + :paramtype custom: + list[~azure.mgmt.resource.policy.v2020_09_01.models.DataManifestCustomResourceFunctionDefinition] + """ super(DataPolicyManifest, self).__init__(**kwargs) self.id = None self.name = None @@ -284,10 +356,10 @@ def __init__( class DataPolicyManifestListResult(msrest.serialization.Model): """List of data policy manifests. - :param value: An array of data policy manifests. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of data policy manifests. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -299,6 +371,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of data policy manifests. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataPolicyManifestListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -329,6 +407,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -372,6 +452,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -389,9 +471,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system assigned + :ivar type: The identity type. This is the only required field when adding a system assigned identity to a resource. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType """ _validation = { @@ -409,6 +491,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system assigned + identity to a resource. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -420,15 +507,15 @@ class NonComplianceMessage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Required. A message that describes why a resource is non-compliant with the + :ivar message: Required. A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. - :type message: str - :param policy_definition_reference_id: The policy definition reference ID within a policy set + :vartype message: str + :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. - :type policy_definition_reference_id: str + :vartype policy_definition_reference_id: str """ _validation = { @@ -444,6 +531,17 @@ def __init__( self, **kwargs ): + """ + :keyword message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :paramtype message: str + :keyword policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :paramtype policy_definition_reference_id: str + """ super(NonComplianceMessage, self).__init__(**kwargs) self.message = kwargs['message'] self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) @@ -452,15 +550,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata """ @@ -475,6 +573,18 @@ def __init__( self, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.allowed_values = kwargs.get('allowed_values', None) @@ -485,20 +595,20 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str - :param strong_type: Used when assigning the policy definition through the portal. Provides a + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str + :ivar strong_type: Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. - :type strong_type: str - :param assign_permissions: Set to true to have Azure portal create role assignments on the + :vartype strong_type: str + :ivar assign_permissions: Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. - :type assign_permissions: bool + :vartype assign_permissions: bool """ _attribute_map = { @@ -513,6 +623,22 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + :keyword strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :paramtype strong_type: str + :keyword assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :paramtype assign_permissions: bool + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.display_name = kwargs.get('display_name', None) @@ -524,8 +650,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -536,6 +662,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -551,35 +681,36 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str + :vartype policy_definition_id: str :ivar scope: The scope for the policy assignment. :vartype scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode - :param non_compliance_messages: The messages that describe why a resource is non-compliant with + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode + :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. - :type non_compliance_messages: + :vartype non_compliance_messages: list[~azure.mgmt.resource.policy.v2020_09_01.models.NonComplianceMessage] """ @@ -611,6 +742,37 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode + :keyword non_compliance_messages: The messages that describe why a resource is non-compliant + with the policy. + :paramtype non_compliance_messages: + list[~azure.mgmt.resource.policy.v2020_09_01.models.NonComplianceMessage] + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -631,10 +793,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -646,6 +808,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -662,24 +830,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] """ @@ -706,6 +874,27 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -724,17 +913,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -753,6 +942,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = kwargs['name'] self.display_name = kwargs.get('display_name', None) @@ -764,10 +966,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -779,6 +981,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -789,18 +997,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -818,6 +1025,20 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs['policy_definition_id'] self.parameters = kwargs.get('parameters', None) @@ -841,25 +1062,25 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. - :type policy_assignment_id: str - :param policy_definition_reference_ids: The policy definition reference ID list when the + :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - :type policy_definition_reference_ids: list[str] - :param exemption_category: Required. The policy exemption category. Possible values are Waiver + :vartype policy_definition_reference_ids: list[str] + :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". - :type exemption_category: str or + :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory - :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) - of the policy exemption. - :type expires_on: ~datetime.datetime - :param display_name: The display name of the policy exemption. - :type display_name: str - :param description: The description of the policy exemption. - :type description: str - :param metadata: The policy exemption metadata. Metadata is an open ended object and is + :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of + the policy exemption. + :vartype expires_on: ~datetime.datetime + :ivar display_name: The display name of the policy exemption. + :vartype display_name: str + :ivar description: The description of the policy exemption. + :vartype description: str + :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any + :vartype metadata: any """ _validation = { @@ -889,6 +1110,28 @@ def __init__( self, **kwargs ): + """ + :keyword policy_assignment_id: Required. The ID of the policy assignment that is being + exempted. + :paramtype policy_assignment_id: str + :keyword policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :paramtype policy_definition_reference_ids: list[str] + :keyword exemption_category: Required. The policy exemption category. Possible values are + Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :paramtype exemption_category: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory + :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :paramtype expires_on: ~datetime.datetime + :keyword display_name: The display name of the policy exemption. + :paramtype display_name: str + :keyword description: The description of the policy exemption. + :paramtype description: str + :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + """ super(PolicyExemption, self).__init__(**kwargs) self.system_data = None self.id = None @@ -908,8 +1151,8 @@ class PolicyExemptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of policy exemptions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :ivar value: An array of policy exemptions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -927,6 +1170,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy exemptions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + """ super(PolicyExemptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -943,26 +1190,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionGroup] """ @@ -989,6 +1236,29 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -1005,10 +1275,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1020,6 +1290,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1028,10 +1304,10 @@ def __init__( class ResourceTypeAliases(msrest.serialization.Model): """The resource type aliases definition. - :param resource_type: The resource type name. - :type resource_type: str - :param aliases: The aliases for property names. - :type aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] + :ivar resource_type: The resource type name. + :vartype resource_type: str + :ivar aliases: The aliases for property names. + :vartype aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] """ _attribute_map = { @@ -1043,6 +1319,12 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type name. + :paramtype resource_type: str + :keyword aliases: The aliases for property names. + :paramtype aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] + """ super(ResourceTypeAliases, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.aliases = kwargs.get('aliases', None) @@ -1051,21 +1333,21 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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.resource.policy.v2020_09_01.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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1081,6 +1363,23 @@ def __init__( self, **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.resource.policy.v2020_09_01.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.resource.policy.v2020_09_01.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py index 6c2e6aa38bbeb..5a6e3e56fab95 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_models_py3.py @@ -19,17 +19,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathMetadata @@ -58,6 +58,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.policy.v2020_09_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -72,12 +85,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPathMetadata @@ -102,6 +115,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -175,10 +206,10 @@ def __init__( class DataEffect(msrest.serialization.Model): """The data effect definition. - :param name: The data effect name. - :type name: str - :param details_schema: The data effect details schema. - :type details_schema: any + :ivar name: The data effect name. + :vartype name: str + :ivar details_schema: The data effect details schema. + :vartype details_schema: any """ _attribute_map = { @@ -193,6 +224,12 @@ def __init__( details_schema: Optional[Any] = None, **kwargs ): + """ + :keyword name: The data effect name. + :paramtype name: str + :keyword details_schema: The data effect details schema. + :paramtype details_schema: any + """ super(DataEffect, self).__init__(**kwargs) self.name = name self.details_schema = details_schema @@ -201,18 +238,18 @@ def __init__( class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """The custom resource function definition. - :param name: The function name as it will appear in the policy rule. eg - 'vault'. - :type name: str - :param fully_qualified_resource_type: The fully qualified control plane resource type that this + :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. + :vartype name: str + :ivar fully_qualified_resource_type: The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - :type fully_qualified_resource_type: str - :param default_properties: The top-level properties that can be selected on the function's + :vartype fully_qualified_resource_type: str + :ivar default_properties: The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and vault().location are supported. - :type default_properties: list[str] - :param allow_custom_properties: A value indicating whether the custom properties within the + :vartype default_properties: list[str] + :ivar allow_custom_properties: A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified in the policy rule eg - vault('2019-06-01'). - :type allow_custom_properties: bool + :vartype allow_custom_properties: bool """ _attribute_map = { @@ -231,6 +268,20 @@ def __init__( allow_custom_properties: Optional[bool] = None, **kwargs ): + """ + :keyword name: The function name as it will appear in the policy rule. eg - 'vault'. + :paramtype name: str + :keyword fully_qualified_resource_type: The fully qualified control plane resource type that + this function represents. eg - 'Microsoft.KeyVault/vaults'. + :paramtype fully_qualified_resource_type: str + :keyword default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :paramtype default_properties: list[str] + :keyword allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :paramtype allow_custom_properties: bool + """ super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) self.name = name self.fully_qualified_resource_type = fully_qualified_resource_type @@ -249,24 +300,24 @@ class DataPolicyManifest(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). :vartype type: str - :param namespaces: The list of namespaces for the data policy manifest. - :type namespaces: list[str] - :param policy_mode: The policy mode of the data policy manifest. - :type policy_mode: str - :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + :ivar namespaces: The list of namespaces for the data policy manifest. + :vartype namespaces: list[str] + :ivar policy_mode: The policy mode of the data policy manifest. + :vartype policy_mode: str + :ivar is_built_in_only: A value indicating whether policy mode is allowed only in built-in definitions. - :type is_built_in_only: bool - :param resource_type_aliases: An array of resource type aliases. - :type resource_type_aliases: + :vartype is_built_in_only: bool + :ivar resource_type_aliases: An array of resource type aliases. + :vartype resource_type_aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.ResourceTypeAliases] - :param effects: The effect definition. - :type effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] - :param field_values: The non-alias field accessor values that can be used in the policy rule. - :type field_values: list[str] - :param standard: The standard resource functions (subscription and/or resourceGroup). - :type standard: list[str] - :param custom: An array of data manifest custom resource definition. - :type custom: + :ivar effects: The effect definition. + :vartype effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] + :ivar field_values: The non-alias field accessor values that can be used in the policy rule. + :vartype field_values: list[str] + :ivar standard: The standard resource functions (subscription and/or resourceGroup). + :vartype standard: list[str] + :ivar custom: An array of data manifest custom resource definition. + :vartype custom: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataManifestCustomResourceFunctionDefinition] """ @@ -303,6 +354,27 @@ def __init__( custom: Optional[List["DataManifestCustomResourceFunctionDefinition"]] = None, **kwargs ): + """ + :keyword namespaces: The list of namespaces for the data policy manifest. + :paramtype namespaces: list[str] + :keyword policy_mode: The policy mode of the data policy manifest. + :paramtype policy_mode: str + :keyword is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :paramtype is_built_in_only: bool + :keyword resource_type_aliases: An array of resource type aliases. + :paramtype resource_type_aliases: + list[~azure.mgmt.resource.policy.v2020_09_01.models.ResourceTypeAliases] + :keyword effects: The effect definition. + :paramtype effects: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataEffect] + :keyword field_values: The non-alias field accessor values that can be used in the policy rule. + :paramtype field_values: list[str] + :keyword standard: The standard resource functions (subscription and/or resourceGroup). + :paramtype standard: list[str] + :keyword custom: An array of data manifest custom resource definition. + :paramtype custom: + list[~azure.mgmt.resource.policy.v2020_09_01.models.DataManifestCustomResourceFunctionDefinition] + """ super(DataPolicyManifest, self).__init__(**kwargs) self.id = None self.name = None @@ -320,10 +392,10 @@ def __init__( class DataPolicyManifestListResult(msrest.serialization.Model): """List of data policy manifests. - :param value: An array of data policy manifests. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of data policy manifests. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -338,6 +410,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of data policy manifests. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataPolicyManifestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -368,6 +446,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -411,6 +491,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -428,9 +510,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the resource identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system assigned + :ivar type: The identity type. This is the only required field when adding a system assigned identity to a resource. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType """ _validation = { @@ -450,6 +532,11 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system assigned + identity to a resource. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -461,15 +548,15 @@ class NonComplianceMessage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Required. A message that describes why a resource is non-compliant with the + :ivar message: Required. A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. - :type message: str - :param policy_definition_reference_id: The policy definition reference ID within a policy set + :vartype message: str + :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. - :type policy_definition_reference_id: str + :vartype policy_definition_reference_id: str """ _validation = { @@ -488,6 +575,17 @@ def __init__( policy_definition_reference_id: Optional[str] = None, **kwargs ): + """ + :keyword message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :paramtype message: str + :keyword policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :paramtype policy_definition_reference_id: str + """ super(NonComplianceMessage, self).__init__(**kwargs) self.message = message self.policy_definition_reference_id = policy_definition_reference_id @@ -496,15 +594,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata """ @@ -524,6 +622,18 @@ def __init__( metadata: Optional["ParameterDefinitionsValueMetadata"] = None, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = type self.allowed_values = allowed_values @@ -534,20 +644,20 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str - :param strong_type: Used when assigning the policy definition through the portal. Provides a + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str + :ivar strong_type: Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. - :type strong_type: str - :param assign_permissions: Set to true to have Azure portal create role assignments on the + :vartype strong_type: str + :ivar assign_permissions: Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. - :type assign_permissions: bool + :vartype assign_permissions: bool """ _attribute_map = { @@ -568,6 +678,22 @@ def __init__( assign_permissions: Optional[bool] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + :keyword strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :paramtype strong_type: str + :keyword assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :paramtype assign_permissions: bool + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name @@ -579,8 +705,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -593,6 +719,10 @@ def __init__( value: Optional[Any] = None, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = value @@ -608,35 +738,36 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str + :vartype policy_definition_id: str :ivar scope: The scope for the policy assignment. :vartype scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode - :param non_compliance_messages: The messages that describe why a resource is non-compliant with + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode + :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. - :type non_compliance_messages: + :vartype non_compliance_messages: list[~azure.mgmt.resource.policy.v2020_09_01.models.NonComplianceMessage] """ @@ -679,6 +810,37 @@ def __init__( non_compliance_messages: Optional[List["NonComplianceMessage"]] = None, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2020_09_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.EnforcementMode + :keyword non_compliance_messages: The messages that describe why a resource is non-compliant + with the policy. + :paramtype non_compliance_messages: + list[~azure.mgmt.resource.policy.v2020_09_01.models.NonComplianceMessage] + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -699,10 +861,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -717,6 +879,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -733,24 +901,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] """ @@ -785,6 +953,27 @@ def __init__( parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -803,17 +992,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -838,6 +1027,19 @@ def __init__( additional_metadata_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -849,10 +1051,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -867,6 +1069,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -877,18 +1085,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -911,6 +1118,20 @@ def __init__( group_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -934,25 +1155,25 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. - :type policy_assignment_id: str - :param policy_definition_reference_ids: The policy definition reference ID list when the + :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - :type policy_definition_reference_ids: list[str] - :param exemption_category: Required. The policy exemption category. Possible values are Waiver + :vartype policy_definition_reference_ids: list[str] + :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". - :type exemption_category: str or + :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory - :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) - of the policy exemption. - :type expires_on: ~datetime.datetime - :param display_name: The display name of the policy exemption. - :type display_name: str - :param description: The description of the policy exemption. - :type description: str - :param metadata: The policy exemption metadata. Metadata is an open ended object and is + :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of + the policy exemption. + :vartype expires_on: ~datetime.datetime + :ivar display_name: The display name of the policy exemption. + :vartype display_name: str + :ivar description: The description of the policy exemption. + :vartype description: str + :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any + :vartype metadata: any """ _validation = { @@ -990,6 +1211,28 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword policy_assignment_id: Required. The ID of the policy assignment that is being + exempted. + :paramtype policy_assignment_id: str + :keyword policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :paramtype policy_definition_reference_ids: list[str] + :keyword exemption_category: Required. The policy exemption category. Possible values are + Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :paramtype exemption_category: str or + ~azure.mgmt.resource.policy.v2020_09_01.models.ExemptionCategory + :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :paramtype expires_on: ~datetime.datetime + :keyword display_name: The display name of the policy exemption. + :paramtype display_name: str + :keyword description: The description of the policy exemption. + :paramtype description: str + :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + """ super(PolicyExemption, self).__init__(**kwargs) self.system_data = None self.id = None @@ -1009,8 +1252,8 @@ class PolicyExemptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of policy exemptions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + :ivar value: An array of policy exemptions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1030,6 +1273,10 @@ def __init__( value: Optional[List["PolicyExemption"]] = None, **kwargs ): + """ + :keyword value: An array of policy exemptions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemption] + """ super(PolicyExemptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1046,26 +1293,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policySetDefinitions). :vartype type: str - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionGroup] """ @@ -1100,6 +1347,29 @@ def __init__( policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2020_09_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -1116,10 +1386,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1134,6 +1404,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1142,10 +1418,10 @@ def __init__( class ResourceTypeAliases(msrest.serialization.Model): """The resource type aliases definition. - :param resource_type: The resource type name. - :type resource_type: str - :param aliases: The aliases for property names. - :type aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] + :ivar resource_type: The resource type name. + :vartype resource_type: str + :ivar aliases: The aliases for property names. + :vartype aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] """ _attribute_map = { @@ -1160,6 +1436,12 @@ def __init__( aliases: Optional[List["Alias"]] = None, **kwargs ): + """ + :keyword resource_type: The resource type name. + :paramtype resource_type: str + :keyword aliases: The aliases for property names. + :paramtype aliases: list[~azure.mgmt.resource.policy.v2020_09_01.models.Alias] + """ super(ResourceTypeAliases, self).__init__(**kwargs) self.resource_type = resource_type self.aliases = aliases @@ -1168,21 +1450,21 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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.resource.policy.v2020_09_01.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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2020_09_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1205,6 +1487,23 @@ def __init__( 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.resource.policy.v2020_09_01.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.resource.policy.v2020_09_01.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 diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py index 38d19a1231114..2aff8db04710e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -85,7 +70,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. """ @@ -94,7 +79,7 @@ class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ExemptionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy exemption category. Possible values are Waiver and Mitigated. """ @@ -104,7 +89,7 @@ class ExemptionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: scope. MITIGATED = "Mitigated" -class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The data type of the parameter. """ @@ -116,7 +101,7 @@ class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. """ @@ -125,7 +110,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. This is the only required field when adding a system assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_data_policy_manifests_operations.py index 45d4189060609..4d70409d92c49 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_data_policy_manifests_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_data_policy_manifests_operations.py @@ -5,24 +5,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_by_policy_mode_request( + policy_mode, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}') + path_format_arguments = { + "policyMode": _SERIALIZER.url("policy_mode", policy_mode, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/dataPolicyManifests') + + # 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', skip_quote=True) + + # 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 + ) + +# fmt: on class DataPolicyManifestsOperations(object): """DataPolicyManifestsOperations operations. @@ -45,6 +115,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_policy_mode( self, policy_mode, # type: str @@ -67,25 +138,15 @@ def get_by_policy_mode( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_policy_mode.metadata['url'] # type: ignore - path_format_arguments = { - 'policyMode': self._serialize.url("policy_mode", policy_mode, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_policy_mode_request( + policy_mode=policy_mode, + template_url=self.get_by_policy_mode.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,8 +160,11 @@ def get_by_policy_mode( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -121,8 +185,10 @@ def list( namespace matching the provided value. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] + :return: An iterator like instance of either DataPolicyManifestListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.DataPolicyManifestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] @@ -130,32 +196,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + 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('DataPolicyManifestListResult', pipeline_response) + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -173,6 +236,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_assignments_operations.py index 3754967555a9e..47733e64fc16d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_assignments_operations.py @@ -5,24 +5,406 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_for_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +427,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,26 +459,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,8 +484,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -147,31 +523,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +551,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -217,26 +586,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -250,8 +609,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -290,8 +652,10 @@ def list_for_resource_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -299,39 +663,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +709,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -417,8 +779,10 @@ def list_for_resource( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -426,43 +790,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +844,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id, # type: str @@ -519,8 +885,10 @@ def list_for_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -528,38 +896,33 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -577,11 +940,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -616,8 +981,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -625,38 +992,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -674,11 +1036,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -708,25 +1072,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +1096,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -779,30 +1136,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyAssignment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -816,8 +1163,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -848,25 +1198,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -880,4 +1220,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_definitions_operations.py index 3b175fdbce51e..3b99ef2138872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_definitions_operations.py @@ -5,24 +5,387 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # 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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +408,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +435,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +463,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,26 +490,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,6 +512,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -187,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -220,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -244,25 +586,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,8 +608,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -307,31 +642,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -345,8 +670,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -372,26 +700,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,6 +722,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -430,26 +750,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -463,8 +773,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -498,8 +811,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -507,38 +822,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,11 +866,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter=None, # type: Optional[str] @@ -589,8 +901,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -598,34 +912,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -643,11 +954,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -685,8 +998,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -694,38 +1009,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -743,6 +1053,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_exemptions_operations.py index 27d37e056641d..41fd44f6011b4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_exemptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_exemptions_operations.py @@ -5,24 +5,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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_create_or_update_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions') + 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\._\(\)]+$'), + } + + 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', skip_quote=True) + 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_for_resource_request( + subscription_id, # type: str + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions') + 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\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + 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 + ) + +# fmt: on class PolicyExemptionsOperations(object): """PolicyExemptionsOperations operations. @@ -45,6 +315,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,26 +347,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,6 +369,8 @@ def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def create_or_update( self, scope, # type: str @@ -143,31 +406,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyExemption') + + request = build_create_or_update_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyExemption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +438,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -217,26 +473,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -250,8 +496,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -281,8 +530,10 @@ def list( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -290,36 +541,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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, + filter=filter, + 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, + 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('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,11 +583,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -374,8 +622,10 @@ def list_for_resource_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -383,37 +633,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource_group.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\._\(\)]+$'), - } - 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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,11 +677,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -494,8 +742,10 @@ def list_for_resource( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -503,41 +753,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource.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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -555,11 +805,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id, # type: str @@ -591,8 +843,10 @@ def list_for_management_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -600,36 +854,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,6 +896,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_set_definitions_operations.py index cf759630adb7e..b18004e37b1e2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2020_09_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,387 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # 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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +408,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,31 +435,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,8 +467,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -137,26 +494,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,6 +516,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -192,26 +541,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -249,25 +591,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,8 +613,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -316,8 +651,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -325,38 +662,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -374,11 +706,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter=None, # type: Optional[str] @@ -405,8 +739,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -414,34 +750,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,11 +792,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -493,31 +828,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -535,8 +860,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -563,26 +891,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -595,6 +913,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -621,26 +941,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -654,8 +964,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -693,8 +1006,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2020_09_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -702,38 +1017,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -751,6 +1061,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py index 97237226e124f..89180ab440872 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['PolicyClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py index d9235f9db71a6..3685c0e83a437 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +67,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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json index 42940ef72f18d..558f1ffb30f80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "PolicyClient", "filename": "_policy_client", "description": "To manage and control access to your resources, you can define customized policies and assign them at a scope.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "data_policy_manifests": "DataPolicyManifestsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py index 1410395d86ba8..9608f67e31e76 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_policy_client.py @@ -6,93 +6,97 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyExemptionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: azure.mgmt.resource.policy.v2021_06_01.operations.DataPolicyManifestsOperations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.v2021_06_01.operations.DataPolicyManifestsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2021_06_01.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2021_06_01.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2021_06_01.operations.PolicySetDefinitionsOperations :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.operations.PolicyExemptionsOperations + :vartype policy_exemptions: + azure.mgmt.resource.policy.v2021_06_01.operations.PolicyExemptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py index 63f5892fe30b6..2784ce3f14bf5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._policy_client import PolicyClient __all__ = ['PolicyClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py index cd61c80f5dd79..71841d791aa5d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(PolicyClientConfiguration, 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(PolicyClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py index 3a5c4f828de13..1c8ab6297fee8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/_policy_client.py @@ -6,89 +6,93 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import PolicyClientConfiguration +from .operations import DataPolicyManifestsOperations, PolicyAssignmentsOperations, PolicyDefinitionsOperations, PolicyExemptionsOperations, PolicySetDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import PolicyClientConfiguration -from .operations import DataPolicyManifestsOperations -from .operations import PolicyAssignmentsOperations -from .operations import PolicyDefinitionsOperations -from .operations import PolicySetDefinitionsOperations -from .operations import PolicyExemptionsOperations -from .. import models - - -class PolicyClient(object): +class PolicyClient: """To manage and control access to your resources, you can define customized policies and assign them at a scope. :ivar data_policy_manifests: DataPolicyManifestsOperations operations - :vartype data_policy_manifests: azure.mgmt.resource.policy.v2021_06_01.aio.operations.DataPolicyManifestsOperations + :vartype data_policy_manifests: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.DataPolicyManifestsOperations :ivar policy_assignments: PolicyAssignmentsOperations operations - :vartype policy_assignments: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyAssignmentsOperations + :vartype policy_assignments: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyAssignmentsOperations :ivar policy_definitions: PolicyDefinitionsOperations operations - :vartype policy_definitions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyDefinitionsOperations + :vartype policy_definitions: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyDefinitionsOperations :ivar policy_set_definitions: PolicySetDefinitionsOperations operations - :vartype policy_set_definitions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicySetDefinitionsOperations + :vartype policy_set_definitions: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicySetDefinitionsOperations :ivar policy_exemptions: PolicyExemptionsOperations operations - :vartype policy_exemptions: azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyExemptionsOperations + :vartype policy_exemptions: + azure.mgmt.resource.policy.v2021_06_01.aio.operations.PolicyExemptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._config = PolicyClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_policy_manifests = DataPolicyManifestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_assignments = PolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_definitions = PolicyDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_set_definitions = PolicySetDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_exemptions = PolicyExemptionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.data_policy_manifests = DataPolicyManifestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_assignments = PolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_definitions = PolicyDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policy_exemptions = PolicyExemptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py index 1f4850dfd1096..2ab90beb9c064 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_data_policy_manifests_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._data_policy_manifests_operations import build_get_by_policy_mode_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_policy_mode( self, policy_mode: str, @@ -62,25 +68,15 @@ async def get_by_policy_mode( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_policy_mode.metadata['url'] # type: ignore - path_format_arguments = { - 'policyMode': self._serialize.url("policy_mode", policy_mode, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_policy_mode_request( + policy_mode=policy_mode, + template_url=self.get_by_policy_mode.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,8 +90,11 @@ async def get_by_policy_mode( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -115,8 +114,10 @@ def list( namespace matching the provided value. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] + :return: An iterator like instance of either DataPolicyManifestListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] @@ -124,32 +125,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + 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('DataPolicyManifestListResult', pipeline_response) + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,6 +165,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py index a043621e741bf..efcc5c81563d2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_management_group_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request, build_update_by_id_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,26 +77,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +102,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def create( self, scope: str, @@ -141,31 +140,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +168,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -210,26 +202,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +225,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace_async async def update( self, scope: str, @@ -278,31 +263,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + + request = build_update_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,8 +291,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -355,8 +333,10 @@ def list_for_resource_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -364,39 +344,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -414,11 +390,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -481,8 +459,10 @@ def list_for_resource( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -490,43 +470,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -544,11 +524,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id: str, @@ -582,8 +564,10 @@ def list_for_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -591,38 +575,33 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -640,11 +619,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -678,8 +659,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -687,38 +670,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -736,11 +714,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace_async async def delete_by_id( self, policy_assignment_id: str, @@ -769,25 +749,15 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -803,8 +773,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def create_by_id( self, policy_assignment_id: str, @@ -839,30 +812,20 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -876,8 +839,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, policy_assignment_id: str, @@ -907,25 +873,15 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -939,8 +895,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace_async async def update_by_id( self, policy_assignment_id: str, @@ -975,30 +934,20 @@ async def update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + + request = build_update_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1012,4 +961,6 @@ async def update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + update_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py index f8a9577375428..dfd6f74110d7d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_definition_name: str, @@ -127,26 +126,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -159,6 +148,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_definition_name: str, @@ -180,26 +171,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,8 +194,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_definition_name: str, @@ -236,25 +220,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -268,8 +242,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def create_or_update_at_management_group( self, policy_definition_name: str, @@ -298,31 +275,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -336,8 +303,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_definition_name: str, @@ -362,26 +332,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -394,6 +354,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_definition_name: str, @@ -419,26 +381,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -452,8 +404,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -486,8 +441,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -495,38 +452,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -544,11 +496,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter: Optional[str] = None, @@ -576,8 +530,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -585,34 +541,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -630,11 +583,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -671,8 +626,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -680,38 +637,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,6 +681,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py index ae6dd8ff815ff..b97424b19773e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_exemptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_exemptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_for_management_group_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -71,26 +77,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,6 +99,8 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -137,31 +135,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyExemption') + + request = build_create_or_update_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyExemption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,8 +167,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -210,26 +201,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +224,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -273,8 +257,10 @@ def list( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -282,36 +268,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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, + filter=filter, + 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, + 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('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -329,11 +310,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -365,8 +348,10 @@ def list_for_resource_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -374,37 +359,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource_group.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\._\(\)]+$'), - } - 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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,11 +403,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -484,8 +467,10 @@ def list_for_resource( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -493,41 +478,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource.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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -545,11 +530,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id: str, @@ -580,8 +567,10 @@ def list_for_management_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -589,36 +578,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -636,6 +620,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py index 7be7e86ccd310..bf57061b4213e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/aio/operations/_policy_set_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policy_set_definitions_operations import build_create_or_update_at_management_group_request, build_create_or_update_request, build_delete_at_management_group_request, build_delete_request, build_get_at_management_group_request, build_get_built_in_request, build_get_request, build_list_built_in_request, build_list_by_management_group_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, policy_set_definition_name: str, @@ -66,31 +72,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,8 +104,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete( self, policy_set_definition_name: str, @@ -131,26 +130,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,6 +152,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get( self, policy_set_definition_name: str, @@ -185,26 +176,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +199,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_built_in( self, policy_set_definition_name: str, @@ -241,25 +225,15 @@ async def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,8 +247,11 @@ async def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -307,8 +284,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -316,38 +295,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -365,11 +339,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter: Optional[str] = None, @@ -395,8 +371,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -404,34 +382,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -449,11 +424,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace_async async def create_or_update_at_management_group( self, policy_set_definition_name: str, @@ -482,31 +459,21 @@ async def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -524,8 +491,11 @@ async def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def delete_at_management_group( self, policy_set_definition_name: str, @@ -551,26 +521,16 @@ async def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -583,6 +543,8 @@ async def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_at_management_group( self, policy_set_definition_name: str, @@ -608,26 +570,16 @@ async def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -641,8 +593,11 @@ async def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id: str, @@ -679,8 +634,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -688,38 +645,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -737,6 +689,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py index 0d6a84886d191..cd8a19378ac2f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -121,6 +142,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -129,12 +152,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType """ _attribute_map = { @@ -147,6 +170,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -156,10 +187,10 @@ def __init__( class DataEffect(msrest.serialization.Model): """The data effect definition. - :param name: The data effect name. - :type name: str - :param details_schema: The data effect details schema. - :type details_schema: any + :ivar name: The data effect name. + :vartype name: str + :ivar details_schema: The data effect details schema. + :vartype details_schema: any """ _attribute_map = { @@ -171,6 +202,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The data effect name. + :paramtype name: str + :keyword details_schema: The data effect details schema. + :paramtype details_schema: any + """ super(DataEffect, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.details_schema = kwargs.get('details_schema', None) @@ -179,18 +216,18 @@ def __init__( class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """The custom resource function definition. - :param name: The function name as it will appear in the policy rule. eg - 'vault'. - :type name: str - :param fully_qualified_resource_type: The fully qualified control plane resource type that this + :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. + :vartype name: str + :ivar fully_qualified_resource_type: The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - :type fully_qualified_resource_type: str - :param default_properties: The top-level properties that can be selected on the function's + :vartype fully_qualified_resource_type: str + :ivar default_properties: The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and vault().location are supported. - :type default_properties: list[str] - :param allow_custom_properties: A value indicating whether the custom properties within the + :vartype default_properties: list[str] + :ivar allow_custom_properties: A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified in the policy rule eg - vault('2019-06-01'). - :type allow_custom_properties: bool + :vartype allow_custom_properties: bool """ _attribute_map = { @@ -204,6 +241,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The function name as it will appear in the policy rule. eg - 'vault'. + :paramtype name: str + :keyword fully_qualified_resource_type: The fully qualified control plane resource type that + this function represents. eg - 'Microsoft.KeyVault/vaults'. + :paramtype fully_qualified_resource_type: str + :keyword default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :paramtype default_properties: list[str] + :keyword allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :paramtype allow_custom_properties: bool + """ super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.fully_qualified_resource_type = kwargs.get('fully_qualified_resource_type', None) @@ -222,24 +273,24 @@ class DataPolicyManifest(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). :vartype type: str - :param namespaces: The list of namespaces for the data policy manifest. - :type namespaces: list[str] - :param policy_mode: The policy mode of the data policy manifest. - :type policy_mode: str - :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + :ivar namespaces: The list of namespaces for the data policy manifest. + :vartype namespaces: list[str] + :ivar policy_mode: The policy mode of the data policy manifest. + :vartype policy_mode: str + :ivar is_built_in_only: A value indicating whether policy mode is allowed only in built-in definitions. - :type is_built_in_only: bool - :param resource_type_aliases: An array of resource type aliases. - :type resource_type_aliases: + :vartype is_built_in_only: bool + :ivar resource_type_aliases: An array of resource type aliases. + :vartype resource_type_aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] - :param effects: The effect definition. - :type effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] - :param field_values: The non-alias field accessor values that can be used in the policy rule. - :type field_values: list[str] - :param standard: The standard resource functions (subscription and/or resourceGroup). - :type standard: list[str] - :param custom: An array of data manifest custom resource definition. - :type custom: + :ivar effects: The effect definition. + :vartype effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :ivar field_values: The non-alias field accessor values that can be used in the policy rule. + :vartype field_values: list[str] + :ivar standard: The standard resource functions (subscription and/or resourceGroup). + :vartype standard: list[str] + :ivar custom: An array of data manifest custom resource definition. + :vartype custom: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] """ @@ -267,6 +318,27 @@ def __init__( self, **kwargs ): + """ + :keyword namespaces: The list of namespaces for the data policy manifest. + :paramtype namespaces: list[str] + :keyword policy_mode: The policy mode of the data policy manifest. + :paramtype policy_mode: str + :keyword is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :paramtype is_built_in_only: bool + :keyword resource_type_aliases: An array of resource type aliases. + :paramtype resource_type_aliases: + list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] + :keyword effects: The effect definition. + :paramtype effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :keyword field_values: The non-alias field accessor values that can be used in the policy rule. + :paramtype field_values: list[str] + :keyword standard: The standard resource functions (subscription and/or resourceGroup). + :paramtype standard: list[str] + :keyword custom: An array of data manifest custom resource definition. + :paramtype custom: + list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] + """ super(DataPolicyManifest, self).__init__(**kwargs) self.id = None self.name = None @@ -284,10 +356,10 @@ def __init__( class DataPolicyManifestListResult(msrest.serialization.Model): """List of data policy manifests. - :param value: An array of data policy manifests. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of data policy manifests. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -299,6 +371,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of data policy manifests. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataPolicyManifestListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -329,6 +407,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -372,6 +452,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -391,14 +473,14 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the resource identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system or user + :ivar type: The identity type. This is the only required field when adding a system or user assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType - :param user_assigned_identities: The user identity associated with the policy. The user - identity dictionary key references will be ARM resource ids in the form: + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :ivar user_assigned_identities: The user identity associated with the policy. The user identity + dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.UserAssignedIdentitiesValue] """ @@ -418,6 +500,17 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system or user + assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :keyword user_assigned_identities: The user identity associated with the policy. 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.resource.policy.v2021_06_01.models.UserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -430,15 +523,15 @@ class NonComplianceMessage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Required. A message that describes why a resource is non-compliant with the + :ivar message: Required. A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. - :type message: str - :param policy_definition_reference_id: The policy definition reference ID within a policy set + :vartype message: str + :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. - :type policy_definition_reference_id: str + :vartype policy_definition_reference_id: str """ _validation = { @@ -454,6 +547,17 @@ def __init__( self, **kwargs ): + """ + :keyword message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :paramtype message: str + :keyword policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :paramtype policy_definition_reference_id: str + """ super(NonComplianceMessage, self).__init__(**kwargs) self.message = kwargs['message'] self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) @@ -462,15 +566,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata """ @@ -485,6 +589,18 @@ def __init__( self, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.allowed_values = kwargs.get('allowed_values', None) @@ -495,20 +611,20 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str - :param strong_type: Used when assigning the policy definition through the portal. Provides a + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str + :ivar strong_type: Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. - :type strong_type: str - :param assign_permissions: Set to true to have Azure portal create role assignments on the + :vartype strong_type: str + :ivar assign_permissions: Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. - :type assign_permissions: bool + :vartype assign_permissions: bool """ _attribute_map = { @@ -523,6 +639,22 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + :keyword strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :paramtype strong_type: str + :keyword assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :paramtype assign_permissions: bool + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.display_name = kwargs.get('display_name', None) @@ -534,8 +666,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -546,6 +678,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -561,37 +697,38 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str + :vartype policy_definition_id: str :ivar scope: The scope for the policy assignment. :vartype scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode - :param non_compliance_messages: The messages that describe why a resource is non-compliant with + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. - :type non_compliance_messages: + :vartype non_compliance_messages: list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] """ @@ -625,6 +762,37 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :keyword non_compliance_messages: The messages that describe why a resource is non-compliant + with the policy. + :paramtype non_compliance_messages: + list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -646,10 +814,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -661,6 +829,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -669,11 +843,11 @@ def __init__( class PolicyAssignmentUpdate(msrest.serialization.Model): """PolicyAssignmentUpdate. - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity """ _attribute_map = { @@ -685,6 +859,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + """ super(PolicyAssignmentUpdate, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.identity = kwargs.get('identity', None) @@ -703,24 +884,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] """ @@ -749,6 +930,27 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -768,17 +970,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -797,6 +999,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = kwargs['name'] self.display_name = kwargs.get('display_name', None) @@ -808,10 +1023,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -823,6 +1038,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -833,18 +1054,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -862,6 +1082,20 @@ def __init__( self, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs['policy_definition_id'] self.parameters = kwargs.get('parameters', None) @@ -885,25 +1119,25 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. - :type policy_assignment_id: str - :param policy_definition_reference_ids: The policy definition reference ID list when the + :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - :type policy_definition_reference_ids: list[str] - :param exemption_category: Required. The policy exemption category. Possible values are Waiver + :vartype policy_definition_reference_ids: list[str] + :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". - :type exemption_category: str or + :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory - :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) - of the policy exemption. - :type expires_on: ~datetime.datetime - :param display_name: The display name of the policy exemption. - :type display_name: str - :param description: The description of the policy exemption. - :type description: str - :param metadata: The policy exemption metadata. Metadata is an open ended object and is + :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of + the policy exemption. + :vartype expires_on: ~datetime.datetime + :ivar display_name: The display name of the policy exemption. + :vartype display_name: str + :ivar description: The description of the policy exemption. + :vartype description: str + :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any + :vartype metadata: any """ _validation = { @@ -933,6 +1167,28 @@ def __init__( self, **kwargs ): + """ + :keyword policy_assignment_id: Required. The ID of the policy assignment that is being + exempted. + :paramtype policy_assignment_id: str + :keyword policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :paramtype policy_definition_reference_ids: list[str] + :keyword exemption_category: Required. The policy exemption category. Possible values are + Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :paramtype exemption_category: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory + :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :paramtype expires_on: ~datetime.datetime + :keyword display_name: The display name of the policy exemption. + :paramtype display_name: str + :keyword description: The description of the policy exemption. + :paramtype description: str + :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + """ super(PolicyExemption, self).__init__(**kwargs) self.system_data = None self.id = None @@ -952,8 +1208,8 @@ class PolicyExemptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of policy exemptions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :ivar value: An array of policy exemptions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -971,6 +1227,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy exemptions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + """ super(PolicyExemptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -989,26 +1249,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] """ @@ -1037,6 +1297,29 @@ def __init__( self, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -1054,10 +1337,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1069,6 +1352,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1077,10 +1366,10 @@ def __init__( class ResourceTypeAliases(msrest.serialization.Model): """The resource type aliases definition. - :param resource_type: The resource type name. - :type resource_type: str - :param aliases: The aliases for property names. - :type aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + :ivar resource_type: The resource type name. + :vartype resource_type: str + :ivar aliases: The aliases for property names. + :vartype aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] """ _attribute_map = { @@ -1092,6 +1381,12 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type name. + :paramtype resource_type: str + :keyword aliases: The aliases for property names. + :paramtype aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + """ super(ResourceTypeAliases, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.aliases = kwargs.get('aliases', None) @@ -1100,21 +1395,21 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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.resource.policy.v2021_06_01.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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1130,6 +1425,23 @@ def __init__( self, **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.resource.policy.v2021_06_01.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.resource.policy.v2021_06_01.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -1164,6 +1476,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py index c376b7acdcb6a..9af87342f0b79 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_models_py3.py @@ -19,17 +19,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathMetadata @@ -58,6 +58,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.policy.v2021_06_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -72,12 +85,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPathMetadata @@ -102,6 +115,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -175,10 +206,10 @@ def __init__( class DataEffect(msrest.serialization.Model): """The data effect definition. - :param name: The data effect name. - :type name: str - :param details_schema: The data effect details schema. - :type details_schema: any + :ivar name: The data effect name. + :vartype name: str + :ivar details_schema: The data effect details schema. + :vartype details_schema: any """ _attribute_map = { @@ -193,6 +224,12 @@ def __init__( details_schema: Optional[Any] = None, **kwargs ): + """ + :keyword name: The data effect name. + :paramtype name: str + :keyword details_schema: The data effect details schema. + :paramtype details_schema: any + """ super(DataEffect, self).__init__(**kwargs) self.name = name self.details_schema = details_schema @@ -201,18 +238,18 @@ def __init__( class DataManifestCustomResourceFunctionDefinition(msrest.serialization.Model): """The custom resource function definition. - :param name: The function name as it will appear in the policy rule. eg - 'vault'. - :type name: str - :param fully_qualified_resource_type: The fully qualified control plane resource type that this + :ivar name: The function name as it will appear in the policy rule. eg - 'vault'. + :vartype name: str + :ivar fully_qualified_resource_type: The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - :type fully_qualified_resource_type: str - :param default_properties: The top-level properties that can be selected on the function's + :vartype fully_qualified_resource_type: str + :ivar default_properties: The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and vault().location are supported. - :type default_properties: list[str] - :param allow_custom_properties: A value indicating whether the custom properties within the + :vartype default_properties: list[str] + :ivar allow_custom_properties: A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified in the policy rule eg - vault('2019-06-01'). - :type allow_custom_properties: bool + :vartype allow_custom_properties: bool """ _attribute_map = { @@ -231,6 +268,20 @@ def __init__( allow_custom_properties: Optional[bool] = None, **kwargs ): + """ + :keyword name: The function name as it will appear in the policy rule. eg - 'vault'. + :paramtype name: str + :keyword fully_qualified_resource_type: The fully qualified control plane resource type that + this function represents. eg - 'Microsoft.KeyVault/vaults'. + :paramtype fully_qualified_resource_type: str + :keyword default_properties: The top-level properties that can be selected on the function's + output. eg - [ "name", "location" ] if vault().name and vault().location are supported. + :paramtype default_properties: list[str] + :keyword allow_custom_properties: A value indicating whether the custom properties within the + property bag are allowed. Needs api-version to be specified in the policy rule eg - + vault('2019-06-01'). + :paramtype allow_custom_properties: bool + """ super(DataManifestCustomResourceFunctionDefinition, self).__init__(**kwargs) self.name = name self.fully_qualified_resource_type = fully_qualified_resource_type @@ -249,24 +300,24 @@ class DataPolicyManifest(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/dataPolicyManifests). :vartype type: str - :param namespaces: The list of namespaces for the data policy manifest. - :type namespaces: list[str] - :param policy_mode: The policy mode of the data policy manifest. - :type policy_mode: str - :param is_built_in_only: A value indicating whether policy mode is allowed only in built-in + :ivar namespaces: The list of namespaces for the data policy manifest. + :vartype namespaces: list[str] + :ivar policy_mode: The policy mode of the data policy manifest. + :vartype policy_mode: str + :ivar is_built_in_only: A value indicating whether policy mode is allowed only in built-in definitions. - :type is_built_in_only: bool - :param resource_type_aliases: An array of resource type aliases. - :type resource_type_aliases: + :vartype is_built_in_only: bool + :ivar resource_type_aliases: An array of resource type aliases. + :vartype resource_type_aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] - :param effects: The effect definition. - :type effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] - :param field_values: The non-alias field accessor values that can be used in the policy rule. - :type field_values: list[str] - :param standard: The standard resource functions (subscription and/or resourceGroup). - :type standard: list[str] - :param custom: An array of data manifest custom resource definition. - :type custom: + :ivar effects: The effect definition. + :vartype effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :ivar field_values: The non-alias field accessor values that can be used in the policy rule. + :vartype field_values: list[str] + :ivar standard: The standard resource functions (subscription and/or resourceGroup). + :vartype standard: list[str] + :ivar custom: An array of data manifest custom resource definition. + :vartype custom: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] """ @@ -303,6 +354,27 @@ def __init__( custom: Optional[List["DataManifestCustomResourceFunctionDefinition"]] = None, **kwargs ): + """ + :keyword namespaces: The list of namespaces for the data policy manifest. + :paramtype namespaces: list[str] + :keyword policy_mode: The policy mode of the data policy manifest. + :paramtype policy_mode: str + :keyword is_built_in_only: A value indicating whether policy mode is allowed only in built-in + definitions. + :paramtype is_built_in_only: bool + :keyword resource_type_aliases: An array of resource type aliases. + :paramtype resource_type_aliases: + list[~azure.mgmt.resource.policy.v2021_06_01.models.ResourceTypeAliases] + :keyword effects: The effect definition. + :paramtype effects: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataEffect] + :keyword field_values: The non-alias field accessor values that can be used in the policy rule. + :paramtype field_values: list[str] + :keyword standard: The standard resource functions (subscription and/or resourceGroup). + :paramtype standard: list[str] + :keyword custom: An array of data manifest custom resource definition. + :paramtype custom: + list[~azure.mgmt.resource.policy.v2021_06_01.models.DataManifestCustomResourceFunctionDefinition] + """ super(DataPolicyManifest, self).__init__(**kwargs) self.id = None self.name = None @@ -320,10 +392,10 @@ def __init__( class DataPolicyManifestListResult(msrest.serialization.Model): """List of data policy manifests. - :param value: An array of data policy manifests. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of data policy manifests. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -338,6 +410,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of data policy manifests. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataPolicyManifestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -368,6 +446,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -411,6 +491,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -430,14 +512,14 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the resource identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: The identity type. This is the only required field when adding a system or user + :ivar type: The identity type. This is the only required field when adding a system or user assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType - :param user_assigned_identities: The user identity associated with the policy. The user - identity dictionary key references will be ARM resource ids in the form: + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :ivar user_assigned_identities: The user identity associated with the policy. The user identity + dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.UserAssignedIdentitiesValue] """ @@ -460,6 +542,17 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. This is the only required field when adding a system or user + assigned identity to a resource. Possible values include: "SystemAssigned", "UserAssigned", + "None". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ResourceIdentityType + :keyword user_assigned_identities: The user identity associated with the policy. 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.resource.policy.v2021_06_01.models.UserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -472,15 +565,15 @@ class NonComplianceMessage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Required. A message that describes why a resource is non-compliant with the + :ivar message: Required. A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. - :type message: str - :param policy_definition_reference_id: The policy definition reference ID within a policy set + :vartype message: str + :ivar policy_definition_reference_id: The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. - :type policy_definition_reference_id: str + :vartype policy_definition_reference_id: str """ _validation = { @@ -499,6 +592,17 @@ def __init__( policy_definition_reference_id: Optional[str] = None, **kwargs ): + """ + :keyword message: Required. A message that describes why a resource is non-compliant with the + policy. This is shown in 'deny' error messages and on resource's non-compliant compliance + results. + :paramtype message: str + :keyword policy_definition_reference_id: The policy definition reference ID within a policy set + definition the message is intended for. This is only applicable if the policy assignment + assigns a policy set definition. If this is not provided the message applies to all policies + assigned by this policy assignment. + :paramtype policy_definition_reference_id: str + """ super(NonComplianceMessage, self).__init__(**kwargs) self.message = message self.policy_definition_reference_id = policy_definition_reference_id @@ -507,15 +611,15 @@ def __init__( class ParameterDefinitionsValue(msrest.serialization.Model): """The definition of a parameter that can be provided to the policy. - :param type: The data type of the parameter. Possible values include: "String", "Array", + :ivar type: The data type of the parameter. Possible values include: "String", "Array", "Object", "Boolean", "Integer", "Float", "DateTime". - :type type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType - :param allowed_values: The allowed values for the parameter. - :type allowed_values: list[any] - :param default_value: The default value for the parameter if no value is provided. - :type default_value: any - :param metadata: General metadata for the parameter. - :type metadata: + :vartype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :ivar allowed_values: The allowed values for the parameter. + :vartype allowed_values: list[any] + :ivar default_value: The default value for the parameter if no value is provided. + :vartype default_value: any + :ivar metadata: General metadata for the parameter. + :vartype metadata: ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata """ @@ -535,6 +639,18 @@ def __init__( metadata: Optional["ParameterDefinitionsValueMetadata"] = None, **kwargs ): + """ + :keyword type: The data type of the parameter. Possible values include: "String", "Array", + "Object", "Boolean", "Integer", "Float", "DateTime". + :paramtype type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterType + :keyword allowed_values: The allowed values for the parameter. + :paramtype allowed_values: list[any] + :keyword default_value: The default value for the parameter if no value is provided. + :paramtype default_value: any + :keyword metadata: General metadata for the parameter. + :paramtype metadata: + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValueMetadata + """ super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = type self.allowed_values = allowed_values @@ -545,20 +661,20 @@ def __init__( class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param display_name: The display name for the parameter. - :type display_name: str - :param description: The description of the parameter. - :type description: str - :param strong_type: Used when assigning the policy definition through the portal. Provides a + :vartype additional_properties: dict[str, any] + :ivar display_name: The display name for the parameter. + :vartype display_name: str + :ivar description: The description of the parameter. + :vartype description: str + :ivar strong_type: Used when assigning the policy definition through the portal. Provides a context aware list of values for the user to choose from. - :type strong_type: str - :param assign_permissions: Set to true to have Azure portal create role assignments on the + :vartype strong_type: str + :ivar assign_permissions: Set to true to have Azure portal create role assignments on the resource ID or resource scope value of this parameter during policy assignment. This property is useful in case you wish to assign permissions outside the assignment scope. - :type assign_permissions: bool + :vartype assign_permissions: bool """ _attribute_map = { @@ -579,6 +695,22 @@ def __init__( assign_permissions: Optional[bool] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword display_name: The display name for the parameter. + :paramtype display_name: str + :keyword description: The description of the parameter. + :paramtype description: str + :keyword strong_type: Used when assigning the policy definition through the portal. Provides a + context aware list of values for the user to choose from. + :paramtype strong_type: str + :keyword assign_permissions: Set to true to have Azure portal create role assignments on the + resource ID or resource scope value of this parameter during policy assignment. This property + is useful in case you wish to assign permissions outside the assignment scope. + :paramtype assign_permissions: bool + """ super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name @@ -590,8 +722,8 @@ def __init__( class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. - :param value: The value of the parameter. - :type value: any + :ivar value: The value of the parameter. + :vartype value: any """ _attribute_map = { @@ -604,6 +736,10 @@ def __init__( value: Optional[Any] = None, **kwargs ): + """ + :keyword value: The value of the parameter. + :paramtype value: any + """ super(ParameterValuesValue, self).__init__(**kwargs) self.value = value @@ -619,37 +755,38 @@ class PolicyAssignment(msrest.serialization.Model): :vartype type: str :ivar name: The name of the policy assignment. :vartype name: str - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param display_name: The display name of the policy assignment. - :type display_name: str - :param policy_definition_id: The ID of the policy definition or policy set definition being + :ivar display_name: The display name of the policy assignment. + :vartype display_name: str + :ivar policy_definition_id: The ID of the policy definition or policy set definition being assigned. - :type policy_definition_id: str + :vartype policy_definition_id: str :ivar scope: The scope for the policy assignment. :vartype scope: str - :param not_scopes: The policy's excluded scopes. - :type not_scopes: list[str] - :param parameters: The parameter values for the assigned policy rule. The keys are the - parameter names. - :type parameters: dict[str, + :ivar not_scopes: The policy's excluded scopes. + :vartype not_scopes: list[str] + :ivar parameters: The parameter values for the assigned policy rule. The keys are the parameter + names. + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] - :param description: This message will be part of response in case of policy violation. - :type description: str - :param metadata: The policy assignment metadata. Metadata is an open ended object and is + :ivar description: This message will be part of response in case of policy violation. + :vartype description: str + :ivar metadata: The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param enforcement_mode: The policy assignment enforcement mode. Possible values are Default - and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". - :type enforcement_mode: str or ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode - :param non_compliance_messages: The messages that describe why a resource is non-compliant with + :vartype metadata: any + :ivar enforcement_mode: The policy assignment enforcement mode. Possible values are Default and + DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :vartype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :ivar non_compliance_messages: The messages that describe why a resource is non-compliant with the policy. - :type non_compliance_messages: + :vartype non_compliance_messages: list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] """ @@ -694,6 +831,37 @@ def __init__( non_compliance_messages: Optional[List["NonComplianceMessage"]] = None, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :keyword display_name: The display name of the policy assignment. + :paramtype display_name: str + :keyword policy_definition_id: The ID of the policy definition or policy set definition being + assigned. + :paramtype policy_definition_id: str + :keyword not_scopes: The policy's excluded scopes. + :paramtype not_scopes: list[str] + :keyword parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :keyword description: This message will be part of response in case of policy violation. + :paramtype description: str + :keyword metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword enforcement_mode: The policy assignment enforcement mode. Possible values are Default + and DoNotEnforce. Possible values include: "Default", "DoNotEnforce". Default value: "Default". + :paramtype enforcement_mode: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.EnforcementMode + :keyword non_compliance_messages: The messages that describe why a resource is non-compliant + with the policy. + :paramtype non_compliance_messages: + list[~azure.mgmt.resource.policy.v2021_06_01.models.NonComplianceMessage] + """ super(PolicyAssignment, self).__init__(**kwargs) self.id = None self.type = None @@ -715,10 +883,10 @@ def __init__( class PolicyAssignmentListResult(msrest.serialization.Model): """List of policy assignments. - :param value: An array of policy assignments. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy assignments. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -733,6 +901,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy assignments. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -741,11 +915,11 @@ def __init__( class PolicyAssignmentUpdate(msrest.serialization.Model): """PolicyAssignmentUpdate. - :param location: The location of the policy assignment. Only required when utilizing managed + :ivar location: The location of the policy assignment. Only required when utilizing managed identity. - :type location: str - :param identity: The managed identity associated with the policy assignment. - :type identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + :vartype location: str + :ivar identity: The managed identity associated with the policy assignment. + :vartype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity """ _attribute_map = { @@ -760,6 +934,13 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: The location of the policy assignment. Only required when utilizing managed + identity. + :paramtype location: str + :keyword identity: The managed identity associated with the policy assignment. + :paramtype identity: ~azure.mgmt.resource.policy.v2021_06_01.models.Identity + """ super(PolicyAssignmentUpdate, self).__init__(**kwargs) self.location = location self.identity = identity @@ -778,24 +959,24 @@ class PolicyDefinition(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType - :param mode: The policy definition mode. Some examples are All, Indexed, + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :ivar mode: The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. - :type mode: str - :param display_name: The display name of the policy definition. - :type display_name: str - :param description: The policy definition description. - :type description: str - :param policy_rule: The policy rule. - :type policy_rule: any - :param metadata: The policy definition metadata. Metadata is an open ended object and is + :vartype mode: str + :ivar display_name: The display name of the policy definition. + :vartype display_name: str + :ivar description: The policy definition description. + :vartype description: str + :ivar policy_rule: The policy rule. + :vartype policy_rule: any + :ivar metadata: The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The parameter definitions for parameters used in the policy rule. The keys + :vartype metadata: any + :ivar parameters: The parameter definitions for parameters used in the policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] """ @@ -832,6 +1013,27 @@ def __init__( parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :keyword mode: The policy definition mode. Some examples are All, Indexed, + Microsoft.KeyVault.Data. + :paramtype mode: str + :keyword display_name: The display name of the policy definition. + :paramtype display_name: str + :keyword description: The policy definition description. + :paramtype description: str + :keyword policy_rule: The policy rule. + :paramtype policy_rule: any + :keyword metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + """ super(PolicyDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -851,17 +1053,17 @@ class PolicyDefinitionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the group. - :type name: str - :param display_name: The group's display name. - :type display_name: str - :param category: The group's category. - :type category: str - :param description: The group's description. - :type description: str - :param additional_metadata_id: A resource ID of a resource that contains additional metadata + :ivar name: Required. The name of the group. + :vartype name: str + :ivar display_name: The group's display name. + :vartype display_name: str + :ivar category: The group's category. + :vartype category: str + :ivar description: The group's description. + :vartype description: str + :ivar additional_metadata_id: A resource ID of a resource that contains additional metadata about the group. - :type additional_metadata_id: str + :vartype additional_metadata_id: str """ _validation = { @@ -886,6 +1088,19 @@ def __init__( additional_metadata_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the group. + :paramtype name: str + :keyword display_name: The group's display name. + :paramtype display_name: str + :keyword category: The group's category. + :paramtype category: str + :keyword description: The group's description. + :paramtype description: str + :keyword additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. + :paramtype additional_metadata_id: str + """ super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -897,10 +1112,10 @@ def __init__( class PolicyDefinitionListResult(msrest.serialization.Model): """List of policy definitions. - :param value: An array of policy definitions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -915,6 +1130,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicyDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -925,18 +1146,17 @@ class PolicyDefinitionReference(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param policy_definition_id: Required. The ID of the policy definition or policy set - definition. - :type policy_definition_id: str - :param parameters: The parameter values for the referenced policy rule. The keys are the + :ivar policy_definition_id: Required. The ID of the policy definition or policy set definition. + :vartype policy_definition_id: str + :ivar parameters: The parameter values for the referenced policy rule. The keys are the parameter names. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] - :param policy_definition_reference_id: A unique id (within the policy set definition) for this + :ivar policy_definition_reference_id: A unique id (within the policy set definition) for this policy definition reference. - :type policy_definition_reference_id: str - :param group_names: The name of the groups that this policy definition reference belongs to. - :type group_names: list[str] + :vartype policy_definition_reference_id: str + :ivar group_names: The name of the groups that this policy definition reference belongs to. + :vartype group_names: list[str] """ _validation = { @@ -959,6 +1179,20 @@ def __init__( group_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword policy_definition_id: Required. The ID of the policy definition or policy set + definition. + :paramtype policy_definition_id: str + :keyword parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterValuesValue] + :keyword policy_definition_reference_id: A unique id (within the policy set definition) for + this policy definition reference. + :paramtype policy_definition_reference_id: str + :keyword group_names: The name of the groups that this policy definition reference belongs to. + :paramtype group_names: list[str] + """ super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -982,25 +1216,25 @@ class PolicyExemption(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource (Microsoft.Authorization/policyExemptions). :vartype type: str - :param policy_assignment_id: Required. The ID of the policy assignment that is being exempted. - :type policy_assignment_id: str - :param policy_definition_reference_ids: The policy definition reference ID list when the + :ivar policy_assignment_id: Required. The ID of the policy assignment that is being exempted. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_ids: The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - :type policy_definition_reference_ids: list[str] - :param exemption_category: Required. The policy exemption category. Possible values are Waiver + :vartype policy_definition_reference_ids: list[str] + :ivar exemption_category: Required. The policy exemption category. Possible values are Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". - :type exemption_category: str or + :vartype exemption_category: str or ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory - :param expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) - of the policy exemption. - :type expires_on: ~datetime.datetime - :param display_name: The display name of the policy exemption. - :type display_name: str - :param description: The description of the policy exemption. - :type description: str - :param metadata: The policy exemption metadata. Metadata is an open ended object and is + :ivar expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of + the policy exemption. + :vartype expires_on: ~datetime.datetime + :ivar display_name: The display name of the policy exemption. + :vartype display_name: str + :ivar description: The description of the policy exemption. + :vartype description: str + :ivar metadata: The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any + :vartype metadata: any """ _validation = { @@ -1038,6 +1272,28 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword policy_assignment_id: Required. The ID of the policy assignment that is being + exempted. + :paramtype policy_assignment_id: str + :keyword policy_definition_reference_ids: The policy definition reference ID list when the + associated policy assignment is an assignment of a policy set definition. + :paramtype policy_definition_reference_ids: list[str] + :keyword exemption_category: Required. The policy exemption category. Possible values are + Waiver and Mitigated. Possible values include: "Waiver", "Mitigated". + :paramtype exemption_category: str or + ~azure.mgmt.resource.policy.v2021_06_01.models.ExemptionCategory + :keyword expires_on: The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) + of the policy exemption. + :paramtype expires_on: ~datetime.datetime + :keyword display_name: The display name of the policy exemption. + :paramtype display_name: str + :keyword description: The description of the policy exemption. + :paramtype description: str + :keyword metadata: The policy exemption metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + """ super(PolicyExemption, self).__init__(**kwargs) self.system_data = None self.id = None @@ -1057,8 +1313,8 @@ class PolicyExemptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of policy exemptions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + :ivar value: An array of policy exemptions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1078,6 +1334,10 @@ def __init__( value: Optional[List["PolicyExemption"]] = None, **kwargs ): + """ + :keyword value: An array of policy exemptions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemption] + """ super(PolicyExemptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1096,26 +1356,26 @@ class PolicySetDefinition(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~azure.mgmt.resource.policy.v2021_06_01.models.SystemData - :param policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + :ivar policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". - :type policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType - :param display_name: The display name of the policy set definition. - :type display_name: str - :param description: The policy set definition description. - :type description: str - :param metadata: The policy set definition metadata. Metadata is an open ended object and is + :vartype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :ivar display_name: The display name of the policy set definition. + :vartype display_name: str + :ivar description: The policy set definition description. + :vartype description: str + :ivar metadata: The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. - :type metadata: any - :param parameters: The policy set definition parameters that can be used in policy definition + :vartype metadata: any + :ivar parameters: The policy set definition parameters that can be used in policy definition references. - :type parameters: dict[str, + :vartype parameters: dict[str, ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] - :param policy_definitions: An array of policy definition references. - :type policy_definitions: + :ivar policy_definitions: An array of policy definition references. + :vartype policy_definitions: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy definition references + :ivar policy_definition_groups: The metadata describing groups of policy definition references within the policy set definition. - :type policy_definition_groups: + :vartype policy_definition_groups: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] """ @@ -1152,6 +1412,29 @@ def __init__( policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, **kwargs ): + """ + :keyword policy_type: The type of policy definition. Possible values are NotSpecified, BuiltIn, + Custom, and Static. Possible values include: "NotSpecified", "BuiltIn", "Custom", "Static". + :paramtype policy_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.PolicyType + :keyword display_name: The display name of the policy set definition. + :paramtype display_name: str + :keyword description: The policy set definition description. + :paramtype description: str + :keyword metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. + :paramtype metadata: any + :keyword parameters: The policy set definition parameters that can be used in policy definition + references. + :paramtype parameters: dict[str, + ~azure.mgmt.resource.policy.v2021_06_01.models.ParameterDefinitionsValue] + :keyword policy_definitions: An array of policy definition references. + :paramtype policy_definitions: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionReference] + :keyword policy_definition_groups: The metadata describing groups of policy definition + references within the policy set definition. + :paramtype policy_definition_groups: + list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionGroup] + """ super(PolicySetDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -1169,10 +1452,10 @@ def __init__( class PolicySetDefinitionListResult(msrest.serialization.Model): """List of policy set definitions. - :param value: An array of policy set definitions. - :type value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of policy set definitions. + :vartype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1187,6 +1470,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of policy set definitions. + :paramtype value: list[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PolicySetDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1195,10 +1484,10 @@ def __init__( class ResourceTypeAliases(msrest.serialization.Model): """The resource type aliases definition. - :param resource_type: The resource type name. - :type resource_type: str - :param aliases: The aliases for property names. - :type aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + :ivar resource_type: The resource type name. + :vartype resource_type: str + :ivar aliases: The aliases for property names. + :vartype aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] """ _attribute_map = { @@ -1213,6 +1502,12 @@ def __init__( aliases: Optional[List["Alias"]] = None, **kwargs ): + """ + :keyword resource_type: The resource type name. + :paramtype resource_type: str + :keyword aliases: The aliases for property names. + :paramtype aliases: list[~azure.mgmt.resource.policy.v2021_06_01.models.Alias] + """ super(ResourceTypeAliases, self).__init__(**kwargs) self.resource_type = resource_type self.aliases = aliases @@ -1221,21 +1516,21 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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.resource.policy.v2021_06_01.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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.policy.v2021_06_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1258,6 +1553,23 @@ def __init__( 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.resource.policy.v2021_06_01.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.resource.policy.v2021_06_01.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 @@ -1292,6 +1604,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py index fb61288e515e3..10eb931285027 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/models/_policy_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -85,7 +70,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnforcementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. """ @@ -94,7 +79,7 @@ class EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The policy effect is not enforced during resource creation or update. DO_NOT_ENFORCE = "DoNotEnforce" -class ExemptionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExemptionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy exemption category. Possible values are Waiver and Mitigated. """ @@ -104,7 +89,7 @@ class ExemptionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: scope. MITIGATED = "Mitigated" -class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The data type of the parameter. """ @@ -116,7 +101,7 @@ class ParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FLOAT = "Float" DATE_TIME = "DateTime" -class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. """ @@ -125,7 +110,7 @@ class PolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CUSTOM = "Custom" STATIC = "Static" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. This is the only required field when adding a system or user assigned identity to a resource. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py index a47b59e91a380..ba6f81e7ea165 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_data_policy_manifests_operations.py @@ -5,24 +5,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_by_policy_mode_request( + policy_mode, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}') + path_format_arguments = { + "policyMode": _SERIALIZER.url("policy_mode", policy_mode, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/dataPolicyManifests') + + # 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', skip_quote=True) + + # 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 + ) + +# fmt: on class DataPolicyManifestsOperations(object): """DataPolicyManifestsOperations operations. @@ -45,6 +115,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_policy_mode( self, policy_mode, # type: str @@ -67,25 +138,15 @@ def get_by_policy_mode( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_by_policy_mode.metadata['url'] # type: ignore - path_format_arguments = { - 'policyMode': self._serialize.url("policy_mode", policy_mode, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_policy_mode_request( + policy_mode=policy_mode, + template_url=self.get_by_policy_mode.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,8 +160,11 @@ def get_by_policy_mode( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_policy_mode.metadata = {'url': '/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -121,8 +185,10 @@ def list( namespace matching the provided value. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataPolicyManifestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] + :return: An iterator like instance of either DataPolicyManifestListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.DataPolicyManifestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataPolicyManifestListResult"] @@ -130,32 +196,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + 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('DataPolicyManifestListResult', pipeline_response) + deserialized = self._deserialize("DataPolicyManifestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -173,6 +236,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py index eb4386ba399f0..8ea6b5aa5451c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_assignments_operations.py @@ -5,24 +5,480 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_create_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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_update_request( + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_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, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_for_resource_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_for_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_by_id_request( + policy_assignment_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{policyAssignmentId}') + path_format_arguments = { + "policyAssignmentId": _SERIALIZER.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. @@ -45,6 +501,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,26 +533,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,8 +558,11 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def create( self, scope, # type: str @@ -147,31 +597,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +625,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -217,26 +660,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -250,8 +683,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def update( self, scope, # type: str @@ -286,31 +722,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + + request = build_update_request( + scope=scope, + policy_assignment_name=policy_assignment_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -324,8 +750,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -364,8 +793,10 @@ def list_for_resource_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -373,39 +804,35 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_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_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -423,11 +850,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -491,8 +920,10 @@ def list_for_resource( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -500,43 +931,43 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_for_resource.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_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -554,11 +985,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id, # type: str @@ -593,8 +1026,10 @@ def list_for_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -602,38 +1037,33 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -651,11 +1081,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -690,8 +1122,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] + :return: An iterator like instance of either PolicyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyAssignmentListResult"] @@ -699,38 +1133,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("PolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -748,11 +1177,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + @distributed_trace def delete_by_id( self, policy_assignment_id, # type: str @@ -782,25 +1213,15 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -816,8 +1237,11 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def create_by_id( self, policy_assignment_id, # type: str @@ -853,30 +1277,20 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignment') + + request = build_create_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -890,8 +1304,11 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def get_by_id( self, policy_assignment_id, # type: str @@ -922,25 +1339,15 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + policy_assignment_id=policy_assignment_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -954,8 +1361,11 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + @distributed_trace def update_by_id( self, policy_assignment_id, # type: str @@ -991,30 +1401,20 @@ def update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyAssignmentUpdate') + + request = build_update_by_id_request( + policy_assignment_id=policy_assignment_id, + content_type=content_type, + json=_json, + template_url=self.update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyAssignmentUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1028,4 +1428,6 @@ def update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + update_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py index a3a0f40e12612..d4a02856f372f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_definitions_operations.py @@ -5,24 +5,387 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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( + policy_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_get_built_in_request( + policy_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}') + path_format_arguments = { + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions') + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policyDefinitions') + + # 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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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 + ) + +# fmt: on class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. @@ -45,6 +408,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_definition_name, # type: str @@ -71,31 +435,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -109,8 +463,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_definition_name, # type: str @@ -133,26 +490,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -165,6 +512,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_definition_name, # type: str @@ -187,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_definition_name=policy_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -220,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_definition_name, # type: str @@ -244,25 +586,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_definition_name=policy_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -276,8 +608,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def create_or_update_at_management_group( self, policy_definition_name, # type: str @@ -307,31 +642,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -345,8 +670,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_definition_name, # type: str @@ -372,26 +700,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,6 +722,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_definition_name, # type: str @@ -430,26 +750,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_definition_name=policy_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -463,8 +773,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -498,8 +811,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -507,38 +822,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,11 +866,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter=None, # type: Optional[str] @@ -589,8 +901,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -598,34 +912,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -643,11 +954,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -685,8 +998,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] + :return: An iterator like instance of either PolicyDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDefinitionListResult"] @@ -694,38 +1009,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicyDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicyDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -743,6 +1053,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py index 215486618d079..6106944f9ea33 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_exemptions_operations.py @@ -5,24 +5,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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_create_or_update_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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, + **kwargs + ) + + +def build_get_request( + scope, # type: str + policy_exemption_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "policyExemptionName": _SERIALIZER.url("policy_exemption_name", policy_exemption_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions') + 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\._\(\)]+$'), + } + + 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', skip_quote=True) + 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_for_resource_request( + subscription_id, # type: str + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions') + 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\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + 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_for_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2020-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + 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 + ) + +# fmt: on class PolicyExemptionsOperations(object): """PolicyExemptionsOperations operations. @@ -45,6 +315,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, scope, # type: str @@ -76,26 +347,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -108,6 +369,8 @@ def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def create_or_update( self, scope, # type: str @@ -143,31 +406,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicyExemption') + + request = build_create_or_update_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyExemption') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -185,8 +438,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -217,26 +473,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'policyExemptionName': self._serialize.url("policy_exemption_name", policy_exemption_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + policy_exemption_name=policy_exemption_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -250,8 +496,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -281,8 +530,10 @@ def list( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -290,36 +541,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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, + filter=filter, + 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, + 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('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,11 +583,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name, # type: str @@ -374,8 +622,10 @@ def list_for_resource_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -383,37 +633,33 @@ def list_for_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource_group.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\._\(\)]+$'), - } - 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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=self.list_for_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_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,11 +677,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name, # type: str @@ -494,8 +742,10 @@ def list_for_resource( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -503,41 +753,41 @@ def list_for_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_resource.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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=self.list_for_resource.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_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -555,11 +805,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions'} # type: ignore + @distributed_trace def list_for_management_group( self, management_group_id, # type: str @@ -591,8 +843,10 @@ def list_for_management_group( associated with the give policyAssignmentId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicyExemptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] + :return: An iterator like instance of either PolicyExemptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicyExemptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyExemptionListResult"] @@ -600,36 +854,31 @@ def list_for_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - 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_for_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.list_for_management_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_for_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PolicyExemptionListResult', pipeline_response) + deserialized = self._deserialize("PolicyExemptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,6 +896,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py index 3d9b86a2313db..d7faeeb66557b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2021_06_01/operations/_policy_set_definitions_operations.py @@ -5,24 +5,387 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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, + **kwargs + ) + + +def build_delete_request( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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( + policy_set_definition_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_get_built_in_request( + policy_set_definition_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions') + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_built_in_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Authorization/policySetDefinitions') + + # 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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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, + **kwargs + ) + + +def build_delete_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_at_management_group_request( + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}') + path_format_arguments = { + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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', skip_quote=True) + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # 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 + ) + +# fmt: on class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. @@ -45,6 +408,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, policy_set_definition_name, # type: str @@ -71,31 +435,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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 = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicySetDefinition') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -113,8 +467,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete( self, policy_set_definition_name, # type: str @@ -137,26 +494,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,6 +516,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get( self, policy_set_definition_name, # type: str @@ -192,26 +541,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + policy_set_definition_name=policy_set_definition_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_built_in( self, policy_set_definition_name, # type: str @@ -249,25 +591,15 @@ def get_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_built_in.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_built_in_request( + policy_set_definition_name=policy_set_definition_name, + template_url=self.get_built_in.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,8 +613,11 @@ def get_built_in( return cls(pipeline_response, deserialized, {}) return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -316,8 +651,10 @@ def list( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -325,38 +662,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -374,11 +706,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def list_built_in( self, filter=None, # type: Optional[str] @@ -405,8 +739,10 @@ def list_built_in( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -414,34 +750,31 @@ def list_built_in( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_built_in.metadata['url'] # type: ignore - # 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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_built_in_request( + filter=filter, + top=top, + template_url=self.list_built_in.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_built_in_request( + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,11 +792,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + @distributed_trace def create_or_update_at_management_group( self, policy_set_definition_name, # type: str @@ -493,31 +828,21 @@ def create_or_update_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'PolicySetDefinition') + + request = build_create_or_update_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicySetDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -535,8 +860,11 @@ def create_or_update_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def delete_at_management_group( self, policy_set_definition_name, # type: str @@ -563,26 +891,16 @@ def delete_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.delete_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -595,6 +913,8 @@ def delete_at_management_group( delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def get_at_management_group( self, policy_set_definition_name, # type: str @@ -621,26 +941,16 @@ def get_at_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_request( + policy_set_definition_name=policy_set_definition_name, + management_group_id=management_group_id, + template_url=self.get_at_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -654,8 +964,11 @@ def get_at_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + @distributed_trace def list_by_management_group( self, management_group_id, # type: str @@ -693,8 +1006,10 @@ def list_by_management_group( return 500 records. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PolicySetDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] + :return: An iterator like instance of either PolicySetDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.policy.v2021_06_01.models.PolicySetDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicySetDefinitionListResult"] @@ -702,38 +1017,33 @@ def list_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-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_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - } - url = self._client.format_url(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', skip_quote=True) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + template_url=self.list_by_management_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_management_group_request( + management_group_id=management_group_id, + filter=filter, + top=top, + 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('PolicySetDefinitionListResult', pipeline_response) + deserialized = self._deserialize("PolicySetDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -751,6 +1061,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py index ae0bb66eaafa6..52422f4e9cded 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py index 1aec78a9b4613..43ac3e807845a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/_resource_management_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +69,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ResourceManagementClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py index def81772fce9d..ac0116dee2a39 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py index c062a71eab45e..70cdb036112d7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/aio/_resource_management_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +68,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ResourceManagementClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py index 1cf50efa110f5..0037b5fc60ea8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json index f982b61142f03..8641a04525513 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "ResourceManagementClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployments": "DeploymentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py index 5c506164d3e6c..88385c59f9614 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_resource_management_client.py @@ -6,99 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourceGroupsOperations -from .operations import ResourcesOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """ResourceManagementClient. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2016_02_01.operations.ProvidersOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2016_02_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2016_02_01.operations.ResourceGroupsOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2016_02_01.operations.ResourcesOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_02_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py index af5064afddb3a..e7bc721237360 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py index 7fbec34ad0071..d40cc421610d8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client.py @@ -6,95 +6,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourceGroupsOperations -from .operations import ResourcesOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """ResourceManagementClient. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2016_02_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2016_02_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2016_02_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2016_02_01.aio.operations.ProvidersOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2016_02_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2016_02_01.aio.operations.ResourceGroupsOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2016_02_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2016_02_01.aio.operations.ResourcesOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_02_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2016_02_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployment_operations_operations.py index cd6434ac7dfd6..21a59a79c4efd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,28 +72,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -119,8 +118,10 @@ def list( :param top: Query parameters. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -128,38 +129,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +175,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployments_operations.py index 34aba093e4427..128236413f2a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_request, build_check_existence_request, build_create_or_update_request_initial, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,25 +59,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -85,6 +82,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -99,15 +98,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -121,21 +122,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_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: @@ -147,8 +141,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -172,25 +168,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -200,10 +188,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -216,32 +205,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -259,8 +238,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -278,15 +260,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -298,27 +285,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_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: @@ -330,8 +311,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -355,27 +338,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -389,8 +362,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -413,25 +389,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -444,6 +412,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -469,32 +439,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -512,8 +472,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -536,27 +499,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -570,8 +523,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -589,8 +545,10 @@ def list( :param top: Query parameters. If null is passed returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -598,39 +556,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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 = { - '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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,11 +602,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -672,26 +628,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -705,4 +654,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_providers_operations.py index ba7491795b8df..7b20d4b9d6c12 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -164,7 +156,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -172,38 +165,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -221,11 +209,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -249,28 +239,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -284,4 +263,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resource_groups_operations.py index 6e0460043ba1f..b36667ee2d843 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_list_resources_request, build_patch_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_resources( self, resource_group_name: str, @@ -65,7 +71,8 @@ def list_resources( :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -73,41 +80,37 @@ def list_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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_resources.metadata['url'] # type: 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + template_url=self.list_resources.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_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,11 +128,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -150,24 +155,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,10 +174,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -204,31 +203,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -246,8 +235,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -258,24 +249,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -288,6 +271,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -300,15 +285,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -321,20 +308,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -346,8 +327,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -368,26 +351,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +374,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def patch( self, resource_group_name: str, @@ -428,31 +404,21 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_patch_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -466,8 +432,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -490,31 +459,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -528,8 +487,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -543,8 +505,10 @@ def list( :param top: Query parameters. If null is passed returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -552,38 +516,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -601,6 +560,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resources_operations.py index 412cf7d748f1b..6b79fb99b42f7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_request, build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_move_resources_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,29 +59,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,6 +86,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -104,15 +103,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -123,23 +125,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -151,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -168,11 +167,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -180,40 +180,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -231,11 +226,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -271,26 +268,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -300,10 +291,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -339,26 +332,20 @@ async def delete( } error_map.update(kwargs.pop('error_map', {})) - # 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -371,6 +358,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -408,34 +397,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -453,8 +434,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -471,34 +454,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -514,8 +489,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -546,15 +524,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -570,30 +553,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -605,8 +579,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -641,29 +617,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -677,4 +645,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_tags_operations.py index 89144caf68e7e..4e1dcd42be71f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -175,26 +168,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -212,8 +195,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -233,24 +219,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -263,6 +241,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -271,7 +251,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -279,34 +260,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -324,6 +300,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models.py index 8ecf916ddc0b8..9b91233867317 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """AliasPathType. - :param path: The path of an alias. - :type path: str - :param api_versions: The api versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The api versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The api versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """AliasType. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -85,8 +105,8 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: The debug detail level. - :type detail_level: str + :ivar detail_level: The debug detail level. + :vartype detail_level: str """ _attribute_map = { @@ -97,6 +117,10 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: The debug detail level. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -104,14 +128,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -125,6 +149,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -135,8 +169,8 @@ def __init__( class Deployment(msrest.serialization.Model): """Deployment operation parameters. - :param properties: The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :ivar properties: The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties """ _attribute_map = { @@ -147,6 +181,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) @@ -154,8 +192,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """DeploymentExportResult. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -166,6 +204,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -179,10 +221,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ @@ -201,6 +243,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = kwargs['name'] @@ -210,8 +259,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -222,6 +271,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -229,10 +282,10 @@ def __init__( class DeploymentListResult(msrest.serialization.Model): """List of deployments. - :param value: The list of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -244,6 +297,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -252,12 +311,12 @@ def __init__( class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - :param id: Full deployment operation id. - :type id: str - :param operation_id: Deployment operation id. - :type operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar id: Full deployment operation id. + :vartype id: str + :ivar operation_id: Deployment operation id. + :vartype operation_id: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationProperties """ @@ -271,6 +330,15 @@ def __init__( self, **kwargs ): + """ + :keyword id: Full deployment operation id. + :paramtype id: str + :keyword operation_id: Deployment operation id. + :paramtype operation_id: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.operation_id = kwargs.get('operation_id', None) @@ -280,22 +348,22 @@ def __init__( class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - :param provisioning_state: The state of the provisioning. - :type provisioning_state: str - :param timestamp: The date and time of the operation. - :type timestamp: ~datetime.datetime - :param service_request_id: Deployment operation service request id. - :type service_request_id: str - :param status_code: Operation status code. - :type status_code: str - :param status_message: Operation status message. - :type status_message: any - :param target_resource: The target resource. - :type target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource - :param request: The HTTP request message. - :type request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage - :param response: The HTTP response message. - :type response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar timestamp: The date and time of the operation. + :vartype timestamp: ~datetime.datetime + :ivar service_request_id: Deployment operation service request id. + :vartype service_request_id: str + :ivar status_code: Operation status code. + :vartype status_code: str + :ivar status_message: Operation status message. + :vartype status_message: any + :ivar target_resource: The target resource. + :vartype target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :ivar request: The HTTP request message. + :vartype request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :ivar response: The HTTP response message. + :vartype response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage """ _attribute_map = { @@ -313,6 +381,24 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The state of the provisioning. + :paramtype provisioning_state: str + :keyword timestamp: The date and time of the operation. + :paramtype timestamp: ~datetime.datetime + :keyword service_request_id: Deployment operation service request id. + :paramtype service_request_id: str + :keyword status_code: Operation status code. + :paramtype status_code: str + :keyword status_message: Operation status message. + :paramtype status_message: any + :keyword target_resource: The target resource. + :paramtype target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :keyword request: The HTTP request message. + :paramtype request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :keyword response: The HTTP response message. + :paramtype response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) self.timestamp = kwargs.get('timestamp', None) @@ -327,10 +413,10 @@ def __init__( class DeploymentOperationsListResult(msrest.serialization.Model): """List of deployment operations. - :param value: The list of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -342,6 +428,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -352,20 +444,20 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. It can be a JObject or a well formed JSON string. Use + :ivar template: The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The template URI. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink - :param parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use + :vartype template: any + :ivar template_link: The template URI. Use only one of Template or TemplateLink. + :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :param mode: Required. The deployment mode. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + :vartype parameters: any + :ivar parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :ivar mode: Required. The deployment mode. Possible values include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _validation = { @@ -385,6 +477,23 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. It can be a JObject or a well formed JSON string. Use + only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The template URI. Use only one of Template or TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. It can be a JObject or a well formed JSON string. + Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :keyword mode: Required. The deployment mode. Possible values include: "Incremental", + "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -397,32 +506,32 @@ def __init__( class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - :param provisioning_state: The state of the provisioning. - :type provisioning_state: str - :param correlation_id: The correlation ID of the deployment. - :type correlation_id: str - :param timestamp: The timestamp of the template deployment. - :type timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar correlation_id: The correlation ID of the deployment. + :vartype correlation_id: str + :ivar timestamp: The timestamp of the template deployment. + :vartype timestamp: ~datetime.datetime + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :param mode: The deployment mode. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _attribute_map = { @@ -444,6 +553,34 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The state of the provisioning. + :paramtype provisioning_state: str + :keyword correlation_id: The correlation ID of the deployment. + :paramtype correlation_id: str + :keyword timestamp: The timestamp of the template deployment. + :paramtype timestamp: ~datetime.datetime + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) self.correlation_id = kwargs.get('correlation_id', None) @@ -462,11 +599,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ @@ -479,6 +616,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -509,6 +654,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -552,6 +699,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -563,13 +712,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -581,6 +730,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -597,10 +755,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -621,6 +779,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -640,22 +804,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: Id of the resource that manages this resource. - :type managed_by: str - :param sku: The sku of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: Id of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The sku of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity """ _validation = { @@ -682,6 +846,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: Id of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The sku of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -702,22 +884,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: Id of the resource that manages this resource. - :type managed_by: str - :param sku: The sku of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: Id of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The sku of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -759,6 +941,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: Id of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The sku of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -768,12 +968,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -786,6 +986,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -795,8 +1003,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HttpMessage. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -807,6 +1015,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -820,9 +1032,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -840,6 +1052,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -851,10 +1068,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. URI referencing the template. - :type uri: str - :param content_version: If included it must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. URI referencing the template. + :vartype uri: str + :ivar content_version: If included it must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -870,6 +1087,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. URI referencing the template. + :paramtype uri: str + :keyword content_version: If included it must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -878,14 +1101,14 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str """ _attribute_map = { @@ -899,6 +1122,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -909,14 +1142,14 @@ def __init__( class Provider(msrest.serialization.Model): """Resource provider information. - :param id: The provider id. - :type id: str - :param namespace: The namespace of the provider. - :type namespace: str - :param registration_state: The registration state of the provider. - :type registration_state: str - :param resource_types: The collection of provider resource types. - :type resource_types: + :ivar id: The provider id. + :vartype id: str + :ivar namespace: The namespace of the provider. + :vartype namespace: str + :ivar registration_state: The registration state of the provider. + :vartype registration_state: str + :ivar resource_types: The collection of provider resource types. + :vartype resource_types: list[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderResourceType] """ @@ -931,6 +1164,17 @@ def __init__( self, **kwargs ): + """ + :keyword id: The provider id. + :paramtype id: str + :keyword namespace: The namespace of the provider. + :paramtype namespace: str + :keyword registration_state: The registration state of the provider. + :paramtype registration_state: str + :keyword resource_types: The collection of provider resource types. + :paramtype resource_types: + list[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderResourceType] + """ super(Provider, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.namespace = kwargs.get('namespace', None) @@ -941,10 +1185,10 @@ def __init__( class ProviderListResult(msrest.serialization.Model): """List of resource providers. - :param value: The list of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -956,6 +1200,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -964,16 +1214,16 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created in. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] - :param api_versions: The api version. - :type api_versions: list[str] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created in. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] + :ivar api_versions: The api version. + :vartype api_versions: list[str] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -988,6 +1238,18 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created in. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] + :keyword api_versions: The api version. + :paramtype api_versions: list[str] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1005,16 +1267,16 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The Name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The Name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. Has to be one of the supported Azure Locations, such as West US, East US, West Europe, East Asia, etc. - :type location: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1034,6 +1296,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The Name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. Has to be one of the supported Azure Locations, such as West + US, East US, West Europe, East Asia, etc. + :paramtype location: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -1045,10 +1320,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails """ @@ -1061,6 +1336,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1069,10 +1351,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1084,6 +1366,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1094,10 +1382,10 @@ class ResourceGroupListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1113,6 +1401,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -1139,6 +1433,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1148,10 +1444,10 @@ class ResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of resources. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1167,6 +1463,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -1177,14 +1480,14 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. The error code returned from the server. - :type code: str - :param message: Required. The error message returned from the server. - :type message: str - :param target: The target of the error. - :type target: str - :param details: Validation error. - :type details: + :ivar code: Required. The error code returned from the server. + :vartype code: str + :ivar message: Required. The error message returned from the server. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: Validation error. + :vartype details: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails] """ @@ -1204,6 +1507,17 @@ def __init__( self, **kwargs ): + """ + :keyword code: Required. The error code returned from the server. + :paramtype code: str + :keyword message: Required. The error message returned from the server. + :paramtype message: str + :keyword target: The target of the error. + :paramtype target: str + :keyword details: Validation error. + :paramtype details: + list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails] + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = kwargs['code'] self.message = kwargs['message'] @@ -1214,16 +1528,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1238,6 +1552,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1249,10 +1575,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The ids of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The ids of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1264,6 +1590,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The ids of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1272,18 +1604,18 @@ def __init__( class Sku(msrest.serialization.Model): """Sku for the resource. - :param name: The sku name. - :type name: str - :param tier: The sku tier. - :type tier: str - :param size: The sku size. - :type size: str - :param family: The sku family. - :type family: str - :param model: The sku model. - :type model: str - :param capacity: The sku capacity. - :type capacity: int + :ivar name: The sku name. + :vartype name: str + :ivar tier: The sku tier. + :vartype tier: str + :ivar size: The sku size. + :vartype size: str + :ivar family: The sku family. + :vartype family: str + :ivar model: The sku model. + :vartype model: str + :ivar capacity: The sku capacity. + :vartype capacity: int """ _attribute_map = { @@ -1299,6 +1631,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The sku name. + :paramtype name: str + :keyword tier: The sku tier. + :paramtype tier: str + :keyword size: The sku size. + :paramtype size: str + :keyword family: The sku family. + :paramtype family: str + :keyword model: The sku model. + :paramtype model: str + :keyword capacity: The sku capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1311,8 +1657,8 @@ def __init__( class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -1323,6 +1669,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1330,10 +1680,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: str + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: str """ _attribute_map = { @@ -1345,6 +1695,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: str + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1357,12 +1713,12 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The tag count. - :type count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The tag count. + :vartype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] """ _validation = { @@ -1380,6 +1736,14 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The tag count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1392,10 +1756,10 @@ class TagsListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of tags. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1411,6 +1775,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -1423,10 +1793,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount """ _validation = { @@ -1443,6 +1813,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1452,12 +1828,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1470,6 +1846,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1479,10 +1863,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1494,6 +1878,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1504,10 +1894,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. URI referencing the template. - :type uri: str - :param content_version: If included it must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. URI referencing the template. + :vartype uri: str + :ivar content_version: If included it must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1523,6 +1913,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. URI referencing the template. + :paramtype uri: str + :keyword content_version: If included it must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py index 66277b47ac423..45f273ec2d533 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_models_py3.py @@ -17,10 +17,10 @@ class AliasPathType(msrest.serialization.Model): """AliasPathType. - :param path: The path of an alias. - :type path: str - :param api_versions: The api versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The api versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -35,6 +35,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The api versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -43,10 +49,10 @@ def __init__( class AliasType(msrest.serialization.Model): """AliasType. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] """ _attribute_map = { @@ -61,6 +67,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -69,12 +81,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -91,6 +103,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -100,8 +120,8 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: The debug detail level. - :type detail_level: str + :ivar detail_level: The debug detail level. + :vartype detail_level: str """ _attribute_map = { @@ -114,6 +134,10 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: The debug detail level. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -121,14 +145,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -147,6 +171,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2016_02_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -157,8 +191,8 @@ def __init__( class Deployment(msrest.serialization.Model): """Deployment operation parameters. - :param properties: The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :ivar properties: The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties """ _attribute_map = { @@ -171,6 +205,10 @@ def __init__( properties: Optional["DeploymentProperties"] = None, **kwargs ): + """ + :keyword properties: The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = properties @@ -178,8 +216,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """DeploymentExportResult. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -192,6 +230,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -205,10 +247,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ @@ -230,6 +272,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name @@ -239,8 +288,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -253,6 +302,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -260,10 +313,10 @@ def __init__( class DeploymentListResult(msrest.serialization.Model): """List of deployments. - :param value: The list of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -278,6 +331,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -286,12 +345,12 @@ def __init__( class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - :param id: Full deployment operation id. - :type id: str - :param operation_id: Deployment operation id. - :type operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar id: Full deployment operation id. + :vartype id: str + :ivar operation_id: Deployment operation id. + :vartype operation_id: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationProperties """ @@ -309,6 +368,15 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword id: Full deployment operation id. + :paramtype id: str + :keyword operation_id: Deployment operation id. + :paramtype operation_id: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = id self.operation_id = operation_id @@ -318,22 +386,22 @@ def __init__( class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - :param provisioning_state: The state of the provisioning. - :type provisioning_state: str - :param timestamp: The date and time of the operation. - :type timestamp: ~datetime.datetime - :param service_request_id: Deployment operation service request id. - :type service_request_id: str - :param status_code: Operation status code. - :type status_code: str - :param status_message: Operation status message. - :type status_message: any - :param target_resource: The target resource. - :type target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource - :param request: The HTTP request message. - :type request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage - :param response: The HTTP response message. - :type response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar timestamp: The date and time of the operation. + :vartype timestamp: ~datetime.datetime + :ivar service_request_id: Deployment operation service request id. + :vartype service_request_id: str + :ivar status_code: Operation status code. + :vartype status_code: str + :ivar status_message: Operation status message. + :vartype status_message: any + :ivar target_resource: The target resource. + :vartype target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :ivar request: The HTTP request message. + :vartype request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :ivar response: The HTTP response message. + :vartype response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage """ _attribute_map = { @@ -360,6 +428,24 @@ def __init__( response: Optional["HttpMessage"] = None, **kwargs ): + """ + :keyword provisioning_state: The state of the provisioning. + :paramtype provisioning_state: str + :keyword timestamp: The date and time of the operation. + :paramtype timestamp: ~datetime.datetime + :keyword service_request_id: Deployment operation service request id. + :paramtype service_request_id: str + :keyword status_code: Operation status code. + :paramtype status_code: str + :keyword status_message: Operation status message. + :paramtype status_message: any + :keyword target_resource: The target resource. + :paramtype target_resource: ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :keyword request: The HTTP request message. + :paramtype request: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + :keyword response: The HTTP response message. + :paramtype response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.timestamp = timestamp @@ -374,10 +460,10 @@ def __init__( class DeploymentOperationsListResult(msrest.serialization.Model): """List of deployment operations. - :param value: The list of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -392,6 +478,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -402,20 +494,20 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. It can be a JObject or a well formed JSON string. Use + :ivar template: The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The template URI. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink - :param parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use + :vartype template: any + :ivar template_link: The template URI. Use only one of Template or TemplateLink. + :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :param mode: Required. The deployment mode. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + :vartype parameters: any + :ivar parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :ivar mode: Required. The deployment mode. Possible values include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _validation = { @@ -442,6 +534,23 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword template: The template content. It can be a JObject or a well formed JSON string. Use + only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The template URI. Use only one of Template or TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. It can be a JObject or a well formed JSON string. + Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The parameters URI. Use only one of Parameters or ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :keyword mode: Required. The deployment mode. Possible values include: "Incremental", + "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -454,32 +563,32 @@ def __init__( class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - :param provisioning_state: The state of the provisioning. - :type provisioning_state: str - :param correlation_id: The correlation ID of the deployment. - :type correlation_id: str - :param timestamp: The timestamp of the template deployment. - :type timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar provisioning_state: The state of the provisioning. + :vartype provisioning_state: str + :ivar correlation_id: The correlation ID of the deployment. + :vartype correlation_id: str + :ivar timestamp: The timestamp of the template deployment. + :vartype timestamp: ~datetime.datetime + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink - :param mode: The deployment mode. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values include: "Incremental", "Complete". + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _attribute_map = { @@ -514,6 +623,34 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword provisioning_state: The state of the provisioning. + :paramtype provisioning_state: str + :keyword correlation_id: The correlation ID of the deployment. + :paramtype correlation_id: str + :keyword timestamp: The timestamp of the template deployment. + :paramtype timestamp: ~datetime.datetime + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_02_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_02_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.correlation_id = correlation_id @@ -532,11 +669,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended """ @@ -552,6 +689,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -582,6 +727,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -625,6 +772,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -636,13 +785,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -657,6 +806,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -673,10 +831,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -700,6 +858,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -719,22 +883,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: Id of the resource that manages this resource. - :type managed_by: str - :param sku: The sku of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: Id of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The sku of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity """ _validation = { @@ -770,6 +934,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: Id of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The sku of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -790,22 +972,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: Id of the resource that manages this resource. - :type managed_by: str - :param sku: The sku of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: Id of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The sku of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -856,6 +1038,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: Id of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The sku of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_02_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -865,12 +1065,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -887,6 +1087,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -896,8 +1104,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HttpMessage. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -910,6 +1118,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -923,9 +1135,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -945,6 +1157,11 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -956,10 +1173,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. URI referencing the template. - :type uri: str - :param content_version: If included it must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. URI referencing the template. + :vartype uri: str + :ivar content_version: If included it must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -978,6 +1195,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. URI referencing the template. + :paramtype uri: str + :keyword content_version: If included it must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -986,14 +1209,14 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str """ _attribute_map = { @@ -1012,6 +1235,16 @@ def __init__( promotion_code: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1022,14 +1255,14 @@ def __init__( class Provider(msrest.serialization.Model): """Resource provider information. - :param id: The provider id. - :type id: str - :param namespace: The namespace of the provider. - :type namespace: str - :param registration_state: The registration state of the provider. - :type registration_state: str - :param resource_types: The collection of provider resource types. - :type resource_types: + :ivar id: The provider id. + :vartype id: str + :ivar namespace: The namespace of the provider. + :vartype namespace: str + :ivar registration_state: The registration state of the provider. + :vartype registration_state: str + :ivar resource_types: The collection of provider resource types. + :vartype resource_types: list[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderResourceType] """ @@ -1049,6 +1282,17 @@ def __init__( resource_types: Optional[List["ProviderResourceType"]] = None, **kwargs ): + """ + :keyword id: The provider id. + :paramtype id: str + :keyword namespace: The namespace of the provider. + :paramtype namespace: str + :keyword registration_state: The registration state of the provider. + :paramtype registration_state: str + :keyword resource_types: The collection of provider resource types. + :paramtype resource_types: + list[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderResourceType] + """ super(Provider, self).__init__(**kwargs) self.id = id self.namespace = namespace @@ -1059,10 +1303,10 @@ def __init__( class ProviderListResult(msrest.serialization.Model): """List of resource providers. - :param value: The list of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] - :param next_link: The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1077,6 +1321,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :keyword next_link: The URL to get the next set of results. + :paramtype next_link: str + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1085,16 +1335,16 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created in. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] - :param api_versions: The api version. - :type api_versions: list[str] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created in. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] + :ivar api_versions: The api version. + :vartype api_versions: list[str] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1115,6 +1365,18 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created in. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasType] + :keyword api_versions: The api version. + :paramtype api_versions: list[str] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1132,16 +1394,16 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The Name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The Name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. Has to be one of the supported Azure Locations, such as West US, East US, West Europe, East Asia, etc. - :type location: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1166,6 +1428,19 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The Name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. Has to be one of the supported Azure Locations, such as West + US, East US, West Europe, East Asia, etc. + :paramtype location: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1177,10 +1452,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails """ @@ -1196,6 +1471,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1204,10 +1486,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1222,6 +1504,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1232,10 +1520,10 @@ class ResourceGroupListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1254,6 +1542,12 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: The list of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1280,6 +1574,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1289,10 +1585,10 @@ class ResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of resources. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1311,6 +1607,13 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: The list of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1321,14 +1624,14 @@ class ResourceManagementErrorWithDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. The error code returned from the server. - :type code: str - :param message: Required. The error message returned from the server. - :type message: str - :param target: The target of the error. - :type target: str - :param details: Validation error. - :type details: + :ivar code: Required. The error code returned from the server. + :vartype code: str + :ivar message: Required. The error message returned from the server. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: Validation error. + :vartype details: list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails] """ @@ -1353,6 +1656,17 @@ def __init__( details: Optional[List["ResourceManagementErrorWithDetails"]] = None, **kwargs ): + """ + :keyword code: Required. The error code returned from the server. + :paramtype code: str + :keyword message: Required. The error message returned from the server. + :paramtype message: str + :keyword target: The target of the error. + :paramtype target: str + :keyword details: Validation error. + :paramtype details: + list[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceManagementErrorWithDetails] + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = code self.message = message @@ -1363,16 +1677,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1393,6 +1707,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1404,10 +1730,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The ids of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The ids of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1422,6 +1748,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The ids of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1430,18 +1762,18 @@ def __init__( class Sku(msrest.serialization.Model): """Sku for the resource. - :param name: The sku name. - :type name: str - :param tier: The sku tier. - :type tier: str - :param size: The sku size. - :type size: str - :param family: The sku family. - :type family: str - :param model: The sku model. - :type model: str - :param capacity: The sku capacity. - :type capacity: int + :ivar name: The sku name. + :vartype name: str + :ivar tier: The sku tier. + :vartype tier: str + :ivar size: The sku size. + :vartype size: str + :ivar family: The sku family. + :vartype family: str + :ivar model: The sku model. + :vartype model: str + :ivar capacity: The sku capacity. + :vartype capacity: int """ _attribute_map = { @@ -1464,6 +1796,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The sku name. + :paramtype name: str + :keyword tier: The sku tier. + :paramtype tier: str + :keyword size: The sku size. + :paramtype size: str + :keyword family: The sku family. + :paramtype family: str + :keyword model: The sku model. + :paramtype model: str + :keyword capacity: The sku capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1476,8 +1822,8 @@ def __init__( class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource Id. - :type id: str + :ivar id: Resource Id. + :vartype id: str """ _attribute_map = { @@ -1490,6 +1836,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1497,10 +1847,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: str + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: str """ _attribute_map = { @@ -1515,6 +1865,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: str + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1527,12 +1883,12 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The tag count. - :type count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The tag count. + :vartype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] """ _validation = { @@ -1554,6 +1910,14 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The tag count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1566,10 +1930,10 @@ class TagsListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: The list of tags. - :type value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: The list of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -1588,6 +1952,12 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: The list of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1600,10 +1970,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount """ _validation = { @@ -1623,6 +1993,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_02_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1632,12 +2008,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1654,6 +2030,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1663,10 +2047,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1681,6 +2065,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -1691,10 +2081,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. URI referencing the template. - :type uri: str - :param content_version: If included it must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. URI referencing the template. + :vartype uri: str + :ivar content_version: If included it must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1713,6 +2103,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. URI referencing the template. + :paramtype uri: str + :keyword content_version: If included it must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py index 4bef4c9811477..b78febf5720e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment mode. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py index e7bf1adccca9d..ee209b8821533 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py @@ -5,24 +5,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +131,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -71,28 +158,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +183,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -125,8 +205,10 @@ def list( :param top: Query parameters. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -134,38 +216,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +262,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployments_operations.py index 9acfe29eaa9a4..e91a5eeb7c0ec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployments_operations.py @@ -5,26 +5,347 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_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_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,25 +380,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +403,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -105,15 +420,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -127,21 +444,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_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: @@ -153,8 +463,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -179,25 +491,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,10 +511,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -224,32 +529,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -267,8 +562,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -287,15 +585,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,27 +610,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_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: @@ -339,8 +636,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -365,27 +664,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,8 +688,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -424,25 +716,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -455,6 +739,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -481,32 +767,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -524,8 +800,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -549,27 +828,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -583,8 +852,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -603,8 +875,10 @@ def list( :param top: Query parameters. If null is passed returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -612,39 +886,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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 = { - '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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -662,11 +932,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -687,26 +959,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -720,4 +985,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_providers_operations.py index fc3ac8b1f470b..61e213faa86b6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -171,7 +311,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -179,38 +320,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -228,11 +364,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -257,28 +395,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -292,4 +419,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resource_groups_operations.py index 05adbc443024d..bb4f5776a013f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resource_groups_operations.py @@ -5,26 +5,321 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_resources_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_patch_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +342,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_resources( self, resource_group_name, # type: str @@ -70,7 +366,8 @@ def list_resources( :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -78,41 +375,37 @@ def list_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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_resources.metadata['url'] # type: 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + template_url=self.list_resources.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_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,11 +423,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -156,24 +451,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,10 +470,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -211,31 +500,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -253,8 +532,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -266,24 +547,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -296,6 +569,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -309,15 +584,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -330,20 +607,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -355,8 +626,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -378,26 +651,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -411,8 +674,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def patch( self, resource_group_name, # type: str @@ -439,31 +705,21 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_patch_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -477,8 +733,11 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -502,31 +761,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -540,8 +789,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -556,8 +808,10 @@ def list( :param top: Query parameters. If null is passed returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -565,38 +819,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -614,6 +863,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resources_operations.py index e9398d3ce80f1..7fe57dd330c64 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_resources_operations.py @@ -5,26 +5,321 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -59,29 +354,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +381,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -110,15 +399,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -129,23 +421,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -157,8 +444,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -175,11 +464,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -187,40 +477,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -238,11 +523,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -279,26 +566,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,10 +589,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -348,26 +631,20 @@ def delete( } error_map.update(kwargs.pop('error_map', {})) - # 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -380,6 +657,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -418,34 +697,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -463,8 +734,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _update_initial( self, resource_group_name, # type: str @@ -482,34 +755,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -525,8 +790,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -558,15 +826,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -582,30 +855,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -617,8 +881,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -654,29 +920,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -690,4 +948,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_tags_operations.py index d2a53d834a92d..0d2286c6b65dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -182,26 +338,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -219,8 +365,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -241,24 +390,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -271,6 +412,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -280,7 +423,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -288,34 +432,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,6 +472,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py index c22a2385bdade..378ef13db09eb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json index 60ab0abd314f0..f5b631b2f4189 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployments": "DeploymentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py index 357b6472b34d6..3c1cd0363139c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_resource_management_client.py @@ -6,99 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourceGroupsOperations -from .operations import ResourcesOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2016_09_01.operations.ProvidersOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2016_09_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2016_09_01.operations.ResourceGroupsOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2016_09_01.operations.ResourcesOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_09_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py index bd0ee31988b64..15e84f251469b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py index 06f5216daf6be..ca471927f9ff1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client.py @@ -6,95 +6,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourceGroupsOperations -from .operations import ResourcesOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2016_09_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2016_09_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2016_09_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2016_09_01.aio.operations.ProvidersOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2016_09_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2016_09_01.aio.operations.ResourceGroupsOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2016_09_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2016_09_01.aio.operations.ResourcesOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_09_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2016_09_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployment_operations_operations.py index 42ca03475c77a..a9b9254d445b7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,28 +72,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -119,8 +118,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -128,38 +129,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +175,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployments_operations.py index d812b6df3186c..f77bc467ceec5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_request, build_check_existence_request, build_create_or_update_request_initial, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,25 +59,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -85,6 +82,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -109,15 +108,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -131,21 +132,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -157,8 +151,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -182,25 +178,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -210,10 +198,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -226,32 +215,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,8 +248,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -291,15 +273,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -311,27 +298,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -343,8 +324,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -367,27 +350,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +374,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -430,25 +406,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -461,6 +429,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -488,32 +458,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -531,8 +491,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -555,27 +518,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -589,8 +542,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -609,8 +565,10 @@ def list( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -618,39 +576,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - '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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -668,11 +622,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -692,26 +648,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -725,4 +674,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_providers_operations.py index 3780427e0595f..7dabc5b3fbe52 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resource_groups_operations.py index 4748fcd471852..ad5135dd0a396 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_list_resources_request, build_patch_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_resources( self, resource_group_name: str, @@ -65,7 +71,8 @@ def list_resources( :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -73,41 +80,37 @@ def list_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_resources.metadata['url'] # type: 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + template_url=self.list_resources.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_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,11 +128,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -150,24 +155,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -177,10 +174,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -203,31 +202,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -245,8 +234,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -257,24 +248,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -287,6 +270,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -302,15 +287,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -323,20 +310,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -348,8 +329,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -370,26 +353,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -403,8 +376,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def patch( self, resource_group_name: str, @@ -432,31 +408,21 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_patch_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -470,8 +436,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -494,31 +463,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -532,8 +491,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -547,8 +509,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -556,38 +520,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,6 +564,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resources_operations.py index 8f8a030cd1a95..dcd7bcd395fbc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,29 +59,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,6 +86,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -109,15 +108,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,23 +130,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -156,8 +153,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -173,11 +172,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -185,40 +185,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -236,11 +231,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -277,26 +274,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,10 +297,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -326,26 +318,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -358,6 +344,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -385,15 +373,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -411,24 +401,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -440,6 +420,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -458,34 +439,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -504,8 +477,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -536,15 +512,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -560,30 +541,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -595,6 +567,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -613,34 +586,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +621,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -688,15 +656,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -712,30 +685,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -747,8 +711,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -784,29 +750,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -820,8 +778,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -847,21 +808,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -871,10 +826,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -887,21 +843,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -914,6 +864,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -930,15 +882,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -952,19 +906,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -976,6 +925,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -990,29 +940,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1031,8 +973,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1052,15 +997,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1072,25 +1022,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1102,6 +1048,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1116,29 +1063,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1154,8 +1093,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1175,15 +1117,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1195,25 +1142,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1225,8 +1168,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1251,24 +1196,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1282,4 +1219,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_tags_operations.py index 4b774031ae77b..1f6cca4a476ca 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models.py index 808139a787873..8fbcbb3a59e02 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -85,13 +105,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -102,6 +122,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -109,14 +138,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -130,6 +159,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -142,8 +181,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ _validation = { @@ -158,6 +197,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = kwargs['properties'] @@ -165,8 +208,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -177,6 +220,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -190,10 +237,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ @@ -212,6 +259,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = kwargs['name'] @@ -221,8 +275,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -233,6 +287,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -242,8 +300,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -261,6 +319,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -275,8 +337,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationProperties """ @@ -295,6 +357,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -350,6 +417,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -366,8 +435,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -385,6 +454,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -395,32 +468,32 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -440,6 +513,34 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -460,27 +561,27 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -508,6 +609,29 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -526,11 +650,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ @@ -543,6 +667,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -573,6 +705,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -616,6 +750,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -627,13 +763,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -645,6 +781,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -661,10 +806,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -685,6 +830,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -704,22 +855,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity """ _validation = { @@ -747,6 +898,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -767,22 +936,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -825,6 +994,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -834,12 +1021,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -852,6 +1039,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -861,8 +1056,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HttpMessage. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -873,6 +1068,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -886,9 +1085,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -906,6 +1105,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -917,10 +1121,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -936,6 +1140,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -944,14 +1154,14 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str """ _attribute_map = { @@ -965,6 +1175,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -979,8 +1199,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1005,6 +1225,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1017,8 +1241,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1036,6 +1260,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1044,18 +1272,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1071,6 +1299,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1089,17 +1331,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1120,6 +1362,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -1132,10 +1388,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails """ @@ -1148,6 +1404,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1156,10 +1419,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1171,6 +1434,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1181,8 +1450,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1200,6 +1469,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1226,6 +1499,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1235,8 +1510,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1254,6 +1529,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1293,6 +1573,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1303,16 +1585,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1327,6 +1609,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1338,10 +1632,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1353,6 +1647,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1361,18 +1661,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1388,6 +1688,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1400,8 +1714,8 @@ def __init__( class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1412,6 +1726,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1419,10 +1737,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1434,6 +1752,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1446,13 +1770,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] """ _validation = { @@ -1470,6 +1794,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1482,8 +1815,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1501,6 +1834,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1513,10 +1850,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount """ _validation = { @@ -1533,6 +1870,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1542,12 +1885,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1560,6 +1903,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1569,10 +1920,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1584,6 +1935,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1594,10 +1951,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1613,6 +1970,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1621,10 +1984,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1636,6 +1999,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py index 2c9ce05638580..e78d473372e82 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -99,13 +119,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -118,6 +138,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -125,14 +154,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -151,6 +180,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2016_09_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -163,8 +202,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ _validation = { @@ -181,6 +220,10 @@ def __init__( properties: "DeploymentProperties", **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = properties @@ -188,8 +231,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -202,6 +245,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -215,10 +262,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ @@ -240,6 +287,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name @@ -249,8 +303,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -263,6 +317,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -272,8 +330,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -293,6 +351,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -307,8 +369,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationProperties """ @@ -329,6 +391,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -384,6 +451,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -400,8 +469,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -421,6 +490,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -431,32 +504,32 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -483,6 +556,34 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -503,27 +604,27 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -561,6 +662,29 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2016_09_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2016_09_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -579,11 +703,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended """ @@ -599,6 +723,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -629,6 +761,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -672,6 +806,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -683,13 +819,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -704,6 +840,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -720,10 +865,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -747,6 +892,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -766,22 +917,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity """ _validation = { @@ -818,6 +969,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -838,22 +1007,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -905,6 +1074,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2016_09_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2016_09_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2016_09_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -914,12 +1101,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -936,6 +1123,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -945,8 +1140,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HttpMessage. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -959,6 +1154,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -972,9 +1171,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -994,6 +1193,11 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1005,10 +1209,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1027,6 +1231,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1035,14 +1245,14 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str """ _attribute_map = { @@ -1061,6 +1271,16 @@ def __init__( promotion_code: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1075,8 +1295,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1103,6 +1323,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1115,8 +1339,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1136,6 +1360,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1144,18 +1372,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1178,6 +1406,20 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2016_09_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1196,17 +1438,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1233,6 +1475,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1245,10 +1501,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails """ @@ -1264,6 +1520,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1272,10 +1535,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1290,6 +1553,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1300,8 +1569,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1321,6 +1590,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1347,6 +1620,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1356,8 +1631,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1377,6 +1652,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1416,6 +1696,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1426,16 +1708,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1456,6 +1738,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1467,10 +1761,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1485,6 +1779,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1493,18 +1793,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1527,6 +1827,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1539,8 +1853,8 @@ def __init__( class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1553,6 +1867,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1560,10 +1878,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1578,6 +1896,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1590,13 +1914,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] """ _validation = { @@ -1618,6 +1942,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1630,8 +1963,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1651,6 +1984,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1663,10 +2000,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount """ _validation = { @@ -1686,6 +2023,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2016_09_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1695,12 +2038,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1717,6 +2060,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1726,10 +2077,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1744,6 +2095,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -1754,10 +2111,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1776,6 +2133,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1784,10 +2147,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1802,6 +2165,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py index 159515d73141d..760e6d04925dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py index a410f6846b1f4..a0452a0013032 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py @@ -5,24 +5,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +131,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -71,28 +158,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +183,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -125,8 +205,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -134,38 +216,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +262,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployments_operations.py index 83fb927f0b112..cdd7be29abca5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployments_operations.py @@ -5,26 +5,347 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,25 +380,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +403,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -115,15 +430,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -137,21 +454,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -163,8 +473,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -189,25 +501,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,10 +521,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -234,32 +539,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,8 +572,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -300,15 +598,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -320,27 +623,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -352,8 +649,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -377,27 +676,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -411,8 +700,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -441,25 +733,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,6 +756,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -500,32 +786,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -543,8 +819,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -568,27 +847,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -602,8 +871,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -623,8 +895,10 @@ def list( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -632,39 +906,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - '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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -682,11 +952,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -707,26 +979,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -740,4 +1005,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_providers_operations.py index 81fe1285b6562..645bf97c0a13c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resource_groups_operations.py index 222dbbff71018..8c0578dba215e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resource_groups_operations.py @@ -5,26 +5,321 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_resources_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_patch_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +342,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_resources( self, resource_group_name, # type: str @@ -70,7 +366,8 @@ def list_resources( :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -78,41 +375,37 @@ def list_resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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_resources.metadata['url'] # type: 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + template_url=self.list_resources.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_resources_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,11 +423,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -156,24 +451,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -183,10 +470,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -210,31 +499,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -252,8 +531,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -265,24 +546,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -295,6 +568,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -311,15 +586,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -332,20 +609,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -357,8 +628,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -380,26 +653,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,8 +676,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def patch( self, resource_group_name, # type: str @@ -443,31 +709,21 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_patch_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -481,8 +737,11 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -506,31 +765,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -544,8 +793,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -560,8 +812,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -569,38 +823,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -618,6 +867,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resources_operations.py index ab1e55e612014..5b7592eb99e50 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_resources_operations.py @@ -5,26 +5,480 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -59,29 +513,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +540,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -115,15 +563,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,23 +585,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -162,8 +608,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -180,11 +628,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -192,40 +641,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -243,11 +687,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -285,26 +731,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -314,10 +754,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -335,26 +776,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -367,6 +802,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -395,15 +832,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -421,24 +860,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -450,6 +879,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -469,34 +899,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -515,8 +937,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -548,15 +973,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -572,30 +1002,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -607,6 +1028,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -626,34 +1048,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -669,8 +1083,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -702,15 +1119,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -726,30 +1148,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -761,8 +1174,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -799,29 +1214,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -835,8 +1242,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -863,21 +1273,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -887,10 +1291,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -904,21 +1309,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,6 +1330,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -948,15 +1349,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -970,19 +1373,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -994,6 +1392,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1009,29 +1408,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1050,8 +1441,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1072,15 +1466,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1092,25 +1491,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1122,6 +1517,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1137,29 +1533,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1175,8 +1563,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1197,15 +1588,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1217,25 +1613,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1247,8 +1639,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1274,24 +1668,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1305,4 +1691,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_tags_operations.py index 2441a972c1864..278c2598c4fbb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py index 1c1be8ea2d213..53b00925ceabf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json index 1caea2abfd526..5dd5573c892fa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployments": "DeploymentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py index 5f095677bdf25..67ce4d85af334 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_resource_management_client.py @@ -6,99 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2017_05_10.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2017_05_10.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2017_05_10.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2017_05_10.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2017_05_10.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py index aa74ff2a52ea8..5b346a7d713ad 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py index 719e85ce58e7d..b3366c54883f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client.py @@ -6,95 +6,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2017_05_10.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2017_05_10.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2017_05_10.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2017_05_10.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2017_05_10.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2017_05_10.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2017_05_10.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2017_05_10.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2017_05_10.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2017_05_10.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployment_operations_operations.py index e5b13cdcfb271..ec700d0a30a6c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,28 +72,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -119,8 +118,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -128,38 +129,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +175,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployments_operations.py index 3cf66c28a7fbc..8e627439951f5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_request, build_check_existence_request, build_create_or_update_request_initial, build_delete_request_initial, build_export_template_request, build_get_request, build_list_by_resource_group_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,25 +59,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -85,6 +82,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -109,15 +108,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -131,21 +132,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -157,8 +151,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -182,25 +178,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -210,10 +198,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -226,32 +215,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,8 +248,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -291,15 +273,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -311,27 +298,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -343,8 +324,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -367,27 +350,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +374,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -430,25 +406,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -461,6 +429,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -488,32 +458,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -531,8 +491,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -555,27 +518,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -589,8 +542,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -609,8 +565,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -618,39 +576,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -668,11 +622,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -692,26 +648,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -725,4 +674,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_providers_operations.py index 74f2549454dd9..e33dc654c1642 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resource_groups_operations.py index b1ca4ebefec71..a6092bc2094fb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -116,31 +116,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,8 +148,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -170,24 +162,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -200,6 +184,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -215,15 +201,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -236,20 +224,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -261,8 +243,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -283,26 +267,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,8 +290,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -345,31 +322,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -383,8 +350,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -407,31 +377,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -445,8 +405,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -460,8 +423,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -469,38 +434,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -518,6 +478,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resources_operations.py index 2b77177fb3fc1..59ec9bf94feee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -61,11 +67,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -73,41 +80,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,6 +128,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -141,29 +145,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,6 +172,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -196,15 +194,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -215,23 +216,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -243,6 +239,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -256,29 +253,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +280,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -313,15 +304,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -332,23 +326,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -360,8 +349,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -377,11 +368,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -389,40 +381,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -440,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -481,26 +470,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -510,10 +493,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -530,26 +514,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -562,6 +540,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -589,15 +569,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -615,24 +597,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -644,6 +616,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -662,34 +635,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -708,8 +673,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -740,15 +708,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -764,30 +737,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -799,6 +763,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -817,34 +782,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -860,8 +817,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -892,15 +852,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -916,30 +881,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -951,8 +907,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -988,29 +946,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1024,8 +974,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1051,21 +1004,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1075,10 +1022,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1091,21 +1039,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1118,6 +1060,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1134,15 +1078,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1156,19 +1102,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1180,6 +1121,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1194,29 +1136,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1235,8 +1169,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1256,15 +1193,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1276,25 +1218,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1306,6 +1244,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1320,29 +1259,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1358,8 +1289,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1379,15 +1313,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1399,25 +1338,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1429,8 +1364,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1455,24 +1392,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1486,4 +1415,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_tags_operations.py index 67965b3761e2a..00f9322adfa24 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models.py index 00ac3ea98f57c..b7ea514688e3c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -85,13 +105,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -102,6 +122,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -109,14 +138,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -130,6 +159,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -142,8 +181,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ _validation = { @@ -158,6 +197,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = kwargs['properties'] @@ -165,8 +208,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -177,6 +220,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -190,10 +237,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ @@ -212,6 +259,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = kwargs['name'] @@ -221,8 +275,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -233,6 +287,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -242,8 +300,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -261,6 +319,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -275,8 +337,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationProperties """ @@ -295,6 +357,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -350,6 +417,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -366,8 +435,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -385,6 +454,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -395,32 +468,32 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -440,6 +513,34 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -460,27 +561,27 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -508,6 +609,29 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -526,11 +650,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ @@ -543,6 +667,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -573,6 +705,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -616,6 +750,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -627,13 +763,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -645,6 +781,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -661,10 +806,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -685,6 +830,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -704,22 +855,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity """ _validation = { @@ -747,6 +898,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -767,22 +936,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -825,6 +994,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -834,12 +1021,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -852,6 +1039,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -861,8 +1056,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -873,6 +1068,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -886,9 +1085,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -906,6 +1105,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -917,10 +1121,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -936,6 +1140,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -944,16 +1154,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -968,6 +1178,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -983,8 +1205,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1009,6 +1231,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1021,8 +1247,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1040,6 +1266,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1048,18 +1278,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1075,6 +1305,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1093,17 +1337,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1124,6 +1368,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -1136,10 +1394,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails """ @@ -1152,6 +1410,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1160,10 +1425,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1175,6 +1440,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1185,8 +1456,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1204,6 +1475,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1212,14 +1487,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1233,6 +1508,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1261,6 +1547,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1270,8 +1558,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1289,6 +1577,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1328,6 +1621,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1338,16 +1633,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: The operation name. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: The operation name. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1362,6 +1657,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: The operation name. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1373,10 +1680,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1388,6 +1695,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1396,18 +1709,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1423,6 +1736,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1435,8 +1762,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1447,6 +1774,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1454,10 +1785,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1469,6 +1800,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1481,13 +1818,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] """ _validation = { @@ -1505,6 +1842,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1517,8 +1863,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1536,6 +1882,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1548,10 +1898,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount """ _validation = { @@ -1568,6 +1918,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1577,12 +1933,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1595,6 +1951,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1604,10 +1968,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1619,6 +1983,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1629,10 +1999,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1648,6 +2018,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1656,10 +2032,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1671,6 +2047,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py index 8de4b306bb1c8..65122e2927977 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -99,13 +119,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -118,6 +138,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -125,14 +154,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -151,6 +180,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2017_05_10.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -163,8 +202,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ _validation = { @@ -181,6 +220,10 @@ def __init__( properties: "DeploymentProperties", **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = properties @@ -188,8 +231,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -202,6 +245,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -215,10 +262,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ @@ -240,6 +287,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name @@ -249,8 +303,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -263,6 +317,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -272,8 +330,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -293,6 +351,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -307,8 +369,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationProperties """ @@ -329,6 +391,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -384,6 +451,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -400,8 +469,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -421,6 +490,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -431,32 +504,32 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -483,6 +556,34 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -503,27 +604,27 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + :vartype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -561,6 +662,29 @@ def __init__( debug_setting: Optional["DebugSetting"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2017_05_10.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2017_05_10.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -579,11 +703,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended """ @@ -599,6 +723,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -629,6 +761,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -672,6 +806,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -683,13 +819,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -704,6 +840,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -720,10 +865,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -747,6 +892,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -766,22 +917,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity """ _validation = { @@ -818,6 +969,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -838,22 +1007,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -905,6 +1074,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2017_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2017_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2017_05_10.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -914,12 +1101,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -936,6 +1123,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -945,8 +1140,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -959,6 +1154,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -972,9 +1171,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. The only acceptable values to pass in are None and + :ivar type: The identity type. The only acceptable values to pass in are None and "SystemAssigned". The default value is None. - :type type: str + :vartype type: str """ _validation = { @@ -994,6 +1193,11 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword type: The identity type. The only acceptable values to pass in are None and + "SystemAssigned". The default value is None. + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1005,10 +1209,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1027,6 +1231,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1035,16 +1245,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1065,6 +1275,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1080,8 +1302,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1108,6 +1330,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1120,8 +1346,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1141,6 +1367,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1149,18 +1379,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1183,6 +1413,20 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2017_05_10.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1201,17 +1445,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1238,6 +1482,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1250,10 +1508,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails """ @@ -1269,6 +1527,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1277,10 +1542,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1295,6 +1560,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1305,8 +1576,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1326,6 +1597,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1334,14 +1609,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1360,6 +1635,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1388,6 +1674,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1397,8 +1685,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1418,6 +1706,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1457,6 +1750,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1467,16 +1762,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: The operation name. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: The operation name. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1497,6 +1792,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: The operation name. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1508,10 +1815,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1526,6 +1833,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1534,18 +1847,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1568,6 +1881,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1580,8 +1907,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1594,6 +1921,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1601,10 +1932,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1619,6 +1950,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1631,13 +1968,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] """ _validation = { @@ -1659,6 +1996,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1671,8 +2017,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1692,6 +2038,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1704,10 +2054,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount """ _validation = { @@ -1727,6 +2077,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2017_05_10.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1736,12 +2092,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1758,6 +2114,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1767,10 +2131,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1785,6 +2149,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -1795,10 +2165,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1817,6 +2187,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1825,10 +2201,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1843,6 +2219,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py index 159515d73141d..760e6d04925dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py index 41873f90deaf4..bfb416056af10 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py @@ -5,24 +5,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +131,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -71,28 +158,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +183,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -125,8 +205,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -134,38 +216,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +262,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployments_operations.py index 6d7157440dfa1..561f39d712227 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployments_operations.py @@ -5,26 +5,347 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,25 +380,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +403,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -115,15 +430,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -137,21 +454,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -163,8 +473,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -189,25 +501,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,10 +521,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -234,32 +539,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,8 +572,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -300,15 +598,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -320,27 +623,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -352,8 +649,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -377,27 +676,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -411,8 +700,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -441,25 +733,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,6 +756,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -500,32 +786,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -543,8 +819,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -568,27 +847,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -602,8 +871,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -623,8 +895,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -632,39 +906,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -682,11 +952,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -707,26 +979,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -740,4 +1005,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_providers_operations.py index 00068ea87df3c..f77e12173a6e4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resource_groups_operations.py index 5c00480c26b91..d58560f6e75f0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -122,31 +368,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +400,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -177,24 +415,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,6 +437,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -223,15 +455,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -244,20 +478,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -269,8 +497,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -292,26 +522,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -325,8 +545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -355,31 +578,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -393,8 +606,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -418,31 +634,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,8 +662,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -472,8 +681,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -481,38 +692,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -530,6 +736,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resources_operations.py index 763b373fc636a..61e9179d56c5b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -66,11 +601,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -78,41 +614,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,6 +662,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -147,29 +680,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,6 +707,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -203,15 +730,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -222,23 +752,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -250,6 +775,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -264,29 +790,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -299,6 +817,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -322,15 +842,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -341,23 +864,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -369,8 +887,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -387,11 +907,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -399,40 +920,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -450,11 +966,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -492,26 +1010,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -521,10 +1033,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -542,26 +1055,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -574,6 +1081,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -602,15 +1111,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -628,24 +1139,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -657,6 +1158,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -676,34 +1178,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -722,8 +1216,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -755,15 +1252,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -779,30 +1281,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -814,6 +1307,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -833,34 +1327,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -876,8 +1362,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -909,15 +1398,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -933,30 +1427,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -968,8 +1453,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1006,29 +1493,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1042,8 +1521,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1070,21 +1552,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1094,10 +1570,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1111,21 +1588,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1138,6 +1609,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1155,15 +1628,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1177,19 +1652,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1201,6 +1671,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1216,29 +1687,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1257,8 +1720,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1279,15 +1745,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1299,25 +1770,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1329,6 +1796,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1344,29 +1812,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1382,8 +1842,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1404,15 +1867,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1424,25 +1892,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1454,8 +1918,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1481,24 +1947,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1512,4 +1970,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_tags_operations.py index 736eabed5f91c..20e73c63de924 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py index 32639be02be42..e1e963dd79e7f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json index 920032a2325c6..42182c9159936 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deployments": "DeploymentsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py index 04f0be563c484..41467de0310f3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_resource_management_client.py @@ -6,99 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2018_02_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2018_02_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2018_02_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2018_02_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_02_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py index a7c74b0b8cf45..c34f895e387bf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py index 24fe136277f16..06807342ae1f5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client.py @@ -6,95 +6,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2018_02_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2018_02_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2018_02_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2018_02_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2018_02_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2018_02_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2018_02_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2018_02_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_02_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2018_02_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployment_operations_operations.py index 191ef5ea1197a..6eed4466df8f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,28 +72,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,8 +97,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -119,8 +118,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -128,38 +129,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,6 +175,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployments_operations.py index 666953106ccd9..f22ec84292c5f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_request, build_check_existence_request, build_create_or_update_request_initial, build_delete_request_initial, build_export_template_request, build_get_request, build_list_by_resource_group_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,25 +59,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -85,6 +82,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -109,15 +108,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -131,21 +132,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -157,8 +151,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -182,25 +178,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -210,10 +198,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -226,32 +215,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,8 +248,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -291,15 +273,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -311,27 +298,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -343,8 +324,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -367,27 +350,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +374,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -430,25 +406,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -461,6 +429,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -488,32 +458,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -531,8 +491,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -555,27 +518,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -589,8 +542,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -609,8 +565,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -618,39 +576,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -668,11 +622,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -692,26 +648,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -725,4 +674,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_providers_operations.py index 316e3513ad220..5ac2e5cff03eb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resource_groups_operations.py index c7b7d88fbad11..1b1f42f123f0a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -116,31 +116,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -158,8 +148,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -170,24 +162,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -200,6 +184,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -215,15 +201,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -236,20 +224,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -261,8 +243,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -283,26 +267,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,8 +290,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -345,31 +322,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -383,8 +350,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -407,31 +377,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -445,8 +405,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -460,8 +423,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -469,38 +434,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -518,6 +478,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resources_operations.py index 41744d4ee86e4..14cb25ca785c0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -61,11 +67,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -73,41 +80,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,6 +128,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -141,29 +145,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -176,6 +172,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -196,15 +194,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -215,23 +216,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -243,6 +239,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -256,29 +253,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +280,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -313,15 +304,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -332,23 +326,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -360,8 +349,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -375,11 +366,12 @@ def list( :type filter: str :param expand: The $expand query parameter. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -387,40 +379,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -438,11 +425,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -479,26 +468,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -508,10 +491,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -528,26 +512,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -560,6 +538,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -587,15 +567,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -613,24 +595,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -642,6 +614,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -660,34 +633,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -706,8 +671,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -738,15 +706,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -762,30 +735,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -797,6 +761,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -815,34 +780,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -858,8 +815,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -890,15 +850,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -914,30 +879,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -949,8 +905,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -986,29 +944,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1022,8 +972,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1049,21 +1002,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1073,10 +1020,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1089,21 +1037,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1116,6 +1058,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1132,15 +1076,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1154,19 +1100,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1178,6 +1119,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1192,29 +1134,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1233,8 +1167,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1254,15 +1191,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1274,25 +1216,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1304,6 +1242,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1318,29 +1257,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1356,8 +1287,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1377,15 +1311,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1397,25 +1336,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1427,8 +1362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1453,24 +1390,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1484,4 +1413,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_tags_operations.py index 7e90bab924a5c..28eba7e19360e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models.py index 927ff88a7869a..418cf6580ff2b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -85,13 +105,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -102,6 +122,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -109,14 +138,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -130,6 +159,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -142,8 +181,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ _validation = { @@ -158,6 +197,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = kwargs['properties'] @@ -165,8 +208,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -177,6 +220,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -190,10 +237,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ @@ -212,6 +259,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = kwargs['name'] @@ -221,8 +275,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -233,6 +287,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -242,8 +300,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -261,6 +319,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -275,8 +337,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationProperties """ @@ -295,6 +357,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -350,6 +417,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -366,8 +435,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -385,6 +454,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -395,34 +468,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment """ _validation = { @@ -443,6 +517,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -464,29 +569,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentExtended """ @@ -516,6 +621,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -535,11 +666,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ @@ -552,6 +683,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -582,6 +721,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -625,6 +766,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -636,13 +779,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -654,6 +797,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -670,10 +822,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -694,6 +846,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -713,22 +871,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity """ _validation = { @@ -756,6 +914,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -776,22 +952,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -834,6 +1010,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -843,12 +1037,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -861,6 +1055,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -870,8 +1072,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -882,6 +1084,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -895,9 +1101,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType """ _validation = { @@ -915,6 +1121,11 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -924,11 +1135,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -940,6 +1151,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -952,11 +1170,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -973,6 +1191,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -984,10 +1209,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1003,6 +1228,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1011,16 +1242,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1035,6 +1266,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1050,8 +1293,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1076,6 +1319,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1088,8 +1335,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1107,6 +1354,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1115,18 +1366,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1142,6 +1393,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1160,17 +1425,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1191,6 +1456,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) @@ -1203,10 +1482,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails """ @@ -1219,6 +1498,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1227,10 +1513,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1242,6 +1528,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1252,8 +1544,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1271,6 +1563,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1279,14 +1575,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1300,6 +1596,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1328,6 +1635,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1337,8 +1646,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1356,6 +1665,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1395,6 +1709,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1405,16 +1721,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1429,6 +1745,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1440,10 +1768,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1455,6 +1783,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1463,18 +1797,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1490,6 +1824,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1502,8 +1850,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1514,6 +1862,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1521,10 +1873,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1536,6 +1888,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1548,13 +1906,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] """ _validation = { @@ -1572,6 +1930,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1584,8 +1951,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1603,6 +1970,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1615,10 +1986,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount """ _validation = { @@ -1635,6 +2006,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1644,12 +2021,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1662,6 +2039,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1671,10 +2056,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1686,6 +2071,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1696,10 +2087,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1715,6 +2106,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1723,10 +2120,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1738,6 +2135,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py index e668225cc22d8..a8164a32411e3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -99,13 +119,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -118,6 +138,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -125,14 +154,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -151,6 +180,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2018_02_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -163,8 +202,8 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ _validation = { @@ -181,6 +220,10 @@ def __init__( properties: "DeploymentProperties", **kwargs ): + """ + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.properties = properties @@ -188,8 +231,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -202,6 +245,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -215,10 +262,10 @@ class DeploymentExtended(msrest.serialization.Model): :ivar id: The ID of the deployment. :vartype id: str - :param name: Required. The name of the deployment. - :type name: str - :param properties: Deployment properties. - :type properties: + :ivar name: Required. The name of the deployment. + :vartype name: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ @@ -240,6 +287,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword name: Required. The name of the deployment. + :paramtype name: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name @@ -249,8 +303,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -263,6 +317,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -272,8 +330,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -293,6 +351,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -307,8 +369,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationProperties """ @@ -329,6 +391,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -384,6 +451,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -400,8 +469,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -421,6 +490,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -431,34 +504,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment """ _validation = { @@ -487,6 +561,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -508,29 +613,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentExtended """ @@ -571,6 +676,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_02_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_02_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_02_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -590,11 +721,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended """ @@ -610,6 +741,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -640,6 +779,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -683,6 +824,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -694,13 +837,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -715,6 +858,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -731,10 +883,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -758,6 +910,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -777,22 +935,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity """ _validation = { @@ -829,6 +987,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -849,22 +1025,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -916,6 +1092,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_02_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_02_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_02_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -925,12 +1119,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -947,6 +1141,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -956,8 +1158,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -970,6 +1172,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -983,9 +1189,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType """ _validation = { @@ -1005,6 +1211,11 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceIdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1014,11 +1225,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1033,6 +1244,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1045,11 +1263,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1069,6 +1287,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1080,10 +1305,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1102,6 +1327,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1110,16 +1341,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1140,6 +1371,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1155,8 +1398,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1183,6 +1426,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1195,8 +1442,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1216,6 +1463,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1224,18 +1475,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1258,6 +1509,20 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2018_02_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1276,17 +1541,17 @@ class ResourceGroup(msrest.serialization.Model): :ivar id: The ID of the resource group. :vartype id: str - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1313,6 +1578,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1325,10 +1604,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails """ @@ -1344,6 +1623,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1352,10 +1638,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1370,6 +1656,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1380,8 +1672,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1401,6 +1693,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1409,14 +1705,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1435,6 +1731,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1463,6 +1770,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1472,8 +1781,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1493,6 +1802,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1532,6 +1846,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1542,16 +1858,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1572,6 +1888,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1583,10 +1911,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1601,6 +1929,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1609,18 +1943,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1643,6 +1977,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1655,8 +2003,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1669,6 +2017,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1676,10 +2028,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1694,6 +2046,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1706,13 +2064,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] """ _validation = { @@ -1734,6 +2092,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1746,8 +2113,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1767,6 +2134,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1779,10 +2150,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount """ _validation = { @@ -1802,6 +2173,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2018_02_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1811,12 +2188,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1833,6 +2210,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1842,10 +2227,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1860,6 +2245,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -1870,10 +2261,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1892,6 +2283,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1900,10 +2297,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1918,6 +2315,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py index 20e515131352e..02799db402bcc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -37,7 +22,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -45,7 +30,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py index 2f2ce99259e4e..88a8a4a77b1d2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py @@ -5,24 +5,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +131,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -71,28 +158,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,8 +183,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -125,8 +205,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -134,38 +216,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,6 +262,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployments_operations.py index f5104e998f703..19265267d45d3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployments_operations.py @@ -5,26 +5,347 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,25 +380,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,6 +403,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -115,15 +430,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -137,21 +454,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -163,8 +473,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -189,25 +501,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -217,10 +521,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -234,32 +539,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,8 +572,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -300,15 +598,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -320,27 +623,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -352,8 +649,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -377,27 +676,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -411,8 +700,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -441,25 +733,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,6 +756,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -500,32 +786,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -543,8 +819,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -568,27 +847,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -602,8 +871,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -623,8 +895,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -632,39 +906,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -682,11 +952,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -707,26 +979,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -740,4 +1005,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_providers_operations.py index d23050575de0e..bd02fb652137f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resource_groups_operations.py index 3ace73e79e14f..58db445ab815c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -122,31 +368,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +400,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -177,24 +415,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -207,6 +437,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -223,15 +455,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -244,20 +478,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -269,8 +497,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -292,26 +522,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -325,8 +545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -355,31 +578,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -393,8 +606,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -418,31 +634,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,8 +662,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -472,8 +681,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -481,38 +692,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -530,6 +736,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resources_operations.py index 20c7ab0cdcd78..d174559ca199e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -66,11 +601,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -78,41 +614,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,6 +662,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -147,29 +680,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -182,6 +707,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -203,15 +730,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -222,23 +752,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -250,6 +775,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -264,29 +790,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -299,6 +817,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -322,15 +842,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -341,23 +864,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -369,8 +887,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -385,11 +905,12 @@ def list( :type filter: str :param expand: The $expand query parameter. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -397,40 +918,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -448,11 +964,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -490,26 +1008,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -519,10 +1031,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -540,26 +1053,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -572,6 +1079,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -600,15 +1109,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -626,24 +1137,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -655,6 +1156,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -674,34 +1176,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -720,8 +1214,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -753,15 +1250,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -777,30 +1279,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -812,6 +1305,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -831,34 +1325,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -874,8 +1360,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -907,15 +1396,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -931,30 +1425,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -966,8 +1451,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1004,29 +1491,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1040,8 +1519,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1068,21 +1550,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1092,10 +1568,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1109,21 +1586,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1136,6 +1607,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1153,15 +1626,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1175,19 +1650,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1199,6 +1669,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1214,29 +1685,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1255,8 +1718,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1277,15 +1743,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1297,25 +1768,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1327,6 +1794,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1342,29 +1810,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1380,8 +1840,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1402,15 +1865,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1422,25 +1890,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1452,8 +1916,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1479,24 +1945,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1510,4 +1968,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_tags_operations.py index 43810df820ee5..ceef9083f73e2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py index ab2bc48997a82..89ddda12e55a5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json index 8260b69c49842..457aff3f3bd60 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py index 970d673feeaf3..c29a6eafbacef 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2018_05_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2018_05_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2018_05_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2018_05_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2018_05_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_05_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py index fd361d373b236..b8110a036d404 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py index bd15bcea41a0b..f83d211226696 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2018_05_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2018_05_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2018_05_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2018_05_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2018_05_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2018_05_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2018_05_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2018_05_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2018_05_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_05_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2018_05_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployment_operations_operations.py index a3f5588c35d13..136a5b96c5bbb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_subscription_scope_request, build_get_request, build_list_at_subscription_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -63,27 +69,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,8 +93,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -112,8 +111,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -121,37 +122,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -169,11 +166,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -199,28 +198,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -252,8 +244,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -261,38 +255,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,6 +301,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployments_operations.py index 93db409690141..fabdc77b23076 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_subscription_scope_request, build_cancel_request, build_check_existence_at_subscription_scope_request, build_check_existence_request, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_request_initial, build_export_template_at_subscription_scope_request, build_export_template_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_subscription_scope_request, build_list_by_resource_group_request, build_validate_at_subscription_scope_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,24 +58,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -83,6 +80,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -102,15 +101,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -123,20 +124,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -148,8 +143,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -169,24 +166,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -196,10 +185,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -211,31 +201,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -253,8 +233,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -271,15 +254,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -290,26 +278,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -321,8 +304,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -342,26 +327,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -375,8 +350,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -401,24 +379,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -431,6 +401,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -454,31 +426,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -496,8 +458,11 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -517,26 +482,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -550,8 +505,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -566,8 +524,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -575,38 +535,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -624,6 +579,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -640,25 +596,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -671,6 +619,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -695,15 +645,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -717,21 +669,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -743,8 +688,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -768,25 +715,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,10 +735,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -812,32 +752,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -855,8 +785,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -877,15 +810,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -897,27 +835,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -929,8 +861,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -953,27 +887,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -987,8 +911,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -1016,25 +943,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1047,6 +966,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -1074,32 +995,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1117,8 +1028,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -1141,27 +1055,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1175,8 +1079,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -1195,8 +1102,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1204,39 +1113,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1254,11 +1159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -1278,26 +1185,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1311,4 +1211,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py index 01837eef8a38d..1b0df9e423ae4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2018_05_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_providers_operations.py index 4c0a80905b9b7..907014ad174a1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resource_groups_operations.py index cf005b1d8fd80..1b7d01bec8a01 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -118,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -172,24 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -202,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -217,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -238,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -263,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -285,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -318,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -347,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +352,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -409,31 +379,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -447,8 +407,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -464,8 +427,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -473,38 +438,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -522,6 +482,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resources_operations.py index e8d7a634e803c..331e1204b754e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -73,11 +79,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -85,41 +92,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,6 +140,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -153,29 +157,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,6 +184,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -208,15 +206,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -227,23 +228,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -255,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -268,29 +265,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -303,6 +292,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -325,15 +316,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -344,23 +338,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -372,8 +361,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -401,11 +392,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -413,40 +405,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -464,11 +451,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -505,26 +494,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,10 +517,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -554,26 +538,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -586,6 +564,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -613,15 +593,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -639,24 +621,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -668,6 +640,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -686,34 +659,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -732,8 +697,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -764,15 +732,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -788,30 +761,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -823,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -841,34 +806,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -884,8 +841,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -916,15 +876,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -940,30 +905,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -975,8 +931,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1012,29 +970,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1048,8 +998,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1075,21 +1028,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1099,10 +1046,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1115,21 +1063,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1142,6 +1084,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1158,15 +1102,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1180,19 +1126,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1204,6 +1145,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1218,29 +1160,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1259,8 +1193,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1280,15 +1217,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1300,25 +1242,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1330,6 +1268,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1344,29 +1283,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1382,8 +1313,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1403,15 +1337,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1423,25 +1362,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1453,8 +1388,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1479,24 +1416,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1510,4 +1439,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_tags_operations.py index 2ed4abebc488a..b03257c7fd48e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models.py index cebc07bd1ff37..44683ecc18670 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -391,6 +462,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -407,8 +480,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -426,6 +499,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -436,34 +513,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment """ _validation = { @@ -484,6 +562,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -505,29 +614,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentExtended """ @@ -557,6 +666,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -576,11 +711,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ @@ -593,6 +728,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -623,6 +766,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -666,6 +811,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -677,13 +824,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -695,6 +842,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -711,10 +867,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -735,6 +891,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -754,22 +916,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity """ _validation = { @@ -797,6 +959,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -817,22 +997,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -875,6 +1055,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -884,12 +1082,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -902,6 +1100,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -911,8 +1117,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -923,6 +1129,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -936,13 +1146,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -962,6 +1172,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.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.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -972,11 +1192,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -988,6 +1208,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1000,11 +1227,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1021,6 +1248,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1030,10 +1264,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay """ _attribute_map = { @@ -1045,6 +1279,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1053,14 +1293,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1074,6 +1314,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1084,10 +1334,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1099,6 +1349,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1109,10 +1365,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1128,6 +1384,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1136,16 +1398,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1160,6 +1422,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1175,8 +1449,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1201,6 +1475,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1213,8 +1491,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1232,6 +1510,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1240,18 +1522,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1267,6 +1549,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1289,15 +1585,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1321,6 +1617,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1334,10 +1642,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails """ @@ -1350,6 +1658,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1358,10 +1673,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1373,6 +1688,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1383,8 +1704,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1402,6 +1723,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1410,14 +1735,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1431,6 +1756,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1459,6 +1795,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1468,8 +1806,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1487,6 +1825,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1526,6 +1869,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1536,16 +1881,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1560,6 +1905,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1571,10 +1928,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1586,6 +1943,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1594,18 +1957,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1621,6 +1984,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1633,8 +2010,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1645,6 +2022,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1652,10 +2033,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1667,6 +2048,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1679,13 +2066,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] """ _validation = { @@ -1703,6 +2090,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1715,8 +2111,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1734,6 +2130,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1746,10 +2146,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount """ _validation = { @@ -1766,6 +2166,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1775,12 +2181,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1793,6 +2199,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1802,10 +2216,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1817,6 +2231,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1827,10 +2247,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1846,6 +2266,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1854,10 +2280,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1869,6 +2295,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py index d72a930c97788..6c02fcbce38c7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2018_05_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -426,6 +497,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -442,8 +515,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -463,6 +536,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -473,34 +550,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment """ _validation = { @@ -529,6 +607,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -550,29 +659,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentExtended """ @@ -613,6 +722,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2018_05_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2018_05_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2018_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -632,11 +767,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended """ @@ -652,6 +787,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -682,6 +825,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -725,6 +870,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -736,13 +883,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -757,6 +904,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -773,10 +929,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -800,6 +956,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -819,22 +981,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity """ _validation = { @@ -871,6 +1033,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -891,22 +1071,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -958,6 +1138,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2018_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2018_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2018_05_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -967,12 +1165,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -989,6 +1187,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -998,8 +1204,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1012,6 +1218,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1025,13 +1235,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1054,6 +1264,16 @@ def __init__( 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.resource.resources.v2018_05_01.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.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1064,11 +1284,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1083,6 +1303,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1095,11 +1322,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1119,6 +1346,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1128,10 +1362,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay """ _attribute_map = { @@ -1146,6 +1380,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1154,14 +1394,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1180,6 +1420,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1190,10 +1440,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1208,6 +1458,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1218,10 +1474,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1240,6 +1496,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1248,16 +1510,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1278,6 +1540,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1293,8 +1567,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the provider. :vartype registration_state: str :ivar resource_types: The collection of provider resource types. @@ -1321,6 +1595,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1333,8 +1611,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1354,6 +1632,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1362,18 +1644,18 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1396,6 +1678,20 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2018_05_01.models.ZoneMapping] + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1418,15 +1714,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1455,6 +1751,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1468,10 +1776,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails """ @@ -1487,6 +1795,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1495,10 +1810,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1513,6 +1828,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1523,8 +1844,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1544,6 +1865,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1552,14 +1877,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1578,6 +1903,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1606,6 +1942,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1615,8 +1953,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1636,6 +1974,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1675,6 +2018,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1685,16 +2030,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1715,6 +2060,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1726,10 +2083,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1744,6 +2101,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1752,18 +2115,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1786,6 +2149,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1798,8 +2175,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1812,6 +2189,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1819,10 +2200,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1837,6 +2218,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1849,13 +2236,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] """ _validation = { @@ -1877,6 +2264,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1889,8 +2285,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1910,6 +2306,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1922,10 +2322,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount """ _validation = { @@ -1945,6 +2345,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2018_05_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1954,12 +2360,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1976,6 +2382,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1985,10 +2399,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2003,6 +2417,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2013,10 +2433,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2035,6 +2455,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2043,10 +2469,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2061,6 +2487,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py index 20e515131352e..02799db402bcc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -37,7 +22,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -45,7 +30,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py index d70ee043195ee..1de508da5870f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py @@ -5,24 +5,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +205,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -68,27 +229,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +253,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -118,8 +272,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +283,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +327,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -206,28 +360,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,8 +385,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -260,8 +407,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -269,38 +418,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,6 +464,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployments_operations.py index a3e0463fb3b03..ed44f89f0bfc0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployments_operations.py @@ -5,26 +5,614 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -58,24 +646,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -88,6 +668,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -108,15 +690,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -129,20 +713,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -154,8 +732,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -176,24 +756,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,10 +775,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -219,31 +792,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -261,8 +824,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -280,15 +846,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -299,26 +870,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -330,8 +896,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -352,26 +920,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +943,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -412,24 +973,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,6 +995,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -466,31 +1021,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -508,8 +1053,11 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -530,26 +1078,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -563,8 +1101,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -580,8 +1121,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -589,38 +1132,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -638,6 +1176,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -655,25 +1194,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -686,6 +1217,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -711,15 +1244,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -733,21 +1268,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -759,8 +1287,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -785,25 +1315,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -813,10 +1335,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -830,32 +1353,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -873,8 +1386,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -896,15 +1412,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -916,27 +1437,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -948,8 +1463,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -973,27 +1490,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1007,8 +1514,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -1037,25 +1547,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1068,6 +1570,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -1096,32 +1600,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1139,8 +1633,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -1164,27 +1661,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1198,8 +1685,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -1219,8 +1709,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1228,39 +1720,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1278,11 +1766,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -1303,26 +1793,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1336,4 +1819,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py index 73902fc2546a0..b10d76e2ede7a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2018_05_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_providers_operations.py index 9f4d2bbab472d..beb7498403e56 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resource_groups_operations.py index 63eacb250bd34..bf440ba63271c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -124,31 +370,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -166,8 +402,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -179,24 +417,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +439,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -225,15 +457,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -246,20 +480,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -271,8 +499,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -294,26 +524,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,8 +547,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -357,31 +580,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +608,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -420,31 +636,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -458,8 +664,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -476,8 +685,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -485,38 +696,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,6 +740,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resources_operations.py index d7d05b45ae334..7da765f07e733 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -78,11 +613,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -90,41 +626,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,6 +674,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -159,29 +692,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -194,6 +719,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -215,15 +742,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -234,23 +764,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -262,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -276,29 +802,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -311,6 +829,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -334,15 +854,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -353,23 +876,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -381,8 +899,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -411,11 +931,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -423,40 +944,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -474,11 +990,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -516,26 +1034,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,10 +1057,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -566,26 +1079,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -598,6 +1105,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -626,15 +1135,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -652,24 +1163,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -681,6 +1182,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -700,34 +1202,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -746,8 +1240,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -779,15 +1276,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -803,30 +1305,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -838,6 +1331,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -857,34 +1351,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -900,8 +1386,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -933,15 +1422,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -957,30 +1451,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -992,8 +1477,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1030,29 +1517,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1066,8 +1545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1094,21 +1576,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1118,10 +1594,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1135,21 +1612,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1162,6 +1633,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1179,15 +1652,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1201,19 +1676,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1225,6 +1695,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1240,29 +1711,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1281,8 +1744,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1303,15 +1769,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1323,25 +1794,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1353,6 +1820,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1368,29 +1836,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1406,8 +1866,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1428,15 +1891,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1448,25 +1916,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1478,8 +1942,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1505,24 +1971,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1536,4 +1994,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_tags_operations.py index ddf6431e4f68f..d01b510b25f50 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py index b50fa8735af84..890557df13c2d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json index 99acd2f814ebe..7d5a06cf9fc98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py index 4c6ed533a7a0c..e5d0d5227c53b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_03_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_03_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_03_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_03_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_03_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_03_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_03_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_03_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_03_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_03_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py index 4558702f4dac3..d1772a3353c3a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py index 1de8c4169834b..01697650d84ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_03_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_03_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_03_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_03_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_03_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_03_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_03_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_03_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_03_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_03_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_03_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_03_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployment_operations_operations.py index 4972567b3b1f3..1112a1b7ca10c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_subscription_scope_request, build_get_request, build_list_at_subscription_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -63,27 +69,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,8 +93,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -112,8 +111,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -121,37 +122,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -169,11 +166,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -199,28 +198,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -234,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -252,8 +244,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -261,38 +255,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,6 +301,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployments_operations.py index fda7a6016bd4d..b889be69ffdf8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_subscription_scope_request, build_cancel_request, build_check_existence_at_subscription_scope_request, build_check_existence_request, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_request_initial, build_export_template_at_subscription_scope_request, build_export_template_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_subscription_scope_request, build_list_by_resource_group_request, build_validate_at_subscription_scope_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,24 +58,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -83,6 +80,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -102,15 +101,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -123,20 +124,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -148,8 +143,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -169,24 +166,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -196,10 +185,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -211,31 +201,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -253,8 +233,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -271,15 +254,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -290,26 +278,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -321,8 +304,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -342,26 +327,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -375,8 +350,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -401,24 +379,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -431,6 +401,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -454,31 +426,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -496,8 +458,11 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -517,26 +482,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -550,8 +505,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -566,8 +524,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -575,38 +535,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -624,6 +579,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -640,25 +596,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -671,6 +619,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -695,15 +645,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -717,21 +669,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -743,8 +688,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -768,25 +715,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -796,10 +735,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -812,32 +752,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -855,8 +785,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -877,15 +810,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -897,27 +835,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -929,8 +861,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -953,27 +887,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -987,8 +911,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -1016,25 +943,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1047,6 +966,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -1074,32 +995,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1117,8 +1028,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -1141,27 +1055,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1175,8 +1079,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -1195,8 +1102,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1204,39 +1113,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1254,11 +1159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -1278,26 +1185,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1311,4 +1211,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py index d366bdbbeb13a..c35589e5ff691 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_03_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_providers_operations.py index ccb67c8132bfe..518aaf8ce5e5f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resource_groups_operations.py index 33e61c946b433..8a7839afced75 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -118,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -172,24 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -202,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -217,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -238,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -263,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -285,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -318,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -347,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +352,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -409,31 +379,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -447,8 +407,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -464,8 +427,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -473,38 +438,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -522,6 +482,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resources_operations.py index 5ed0a0f0a1fbe..3f519a8ac3e8b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -73,11 +79,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -85,41 +92,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,6 +140,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -153,29 +157,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,6 +184,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -208,15 +206,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -227,23 +228,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -255,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -268,29 +265,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -303,6 +292,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -325,15 +316,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -344,23 +338,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -372,8 +361,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -401,11 +392,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -413,40 +405,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -464,11 +451,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -505,26 +494,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,10 +517,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -554,26 +538,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -586,6 +564,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -613,15 +593,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -639,24 +621,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -668,6 +640,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -686,34 +659,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -732,8 +697,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -764,15 +732,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -788,30 +761,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -823,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -841,34 +806,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -884,8 +841,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -916,15 +876,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -940,30 +905,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -975,8 +931,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1012,29 +970,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1048,8 +998,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1075,21 +1028,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1099,10 +1046,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1115,21 +1063,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1142,6 +1084,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1158,15 +1102,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1180,19 +1126,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1204,6 +1145,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1218,29 +1160,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1259,8 +1193,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1280,15 +1217,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1300,25 +1242,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1330,6 +1268,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1344,29 +1283,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1382,8 +1313,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1403,15 +1337,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1423,25 +1362,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1453,8 +1388,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1479,24 +1416,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1510,4 +1439,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_tags_operations.py index 510debe59f7fa..2ce3ddd464d80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models.py index b0812105328a5..90e9584f8c723 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -391,6 +462,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -407,8 +480,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -426,6 +499,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -436,34 +513,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment """ _validation = { @@ -484,6 +562,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -505,29 +614,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentExtended """ @@ -557,6 +666,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -576,11 +711,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ @@ -593,6 +728,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -623,6 +766,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -666,6 +811,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -677,13 +824,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -695,6 +842,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -711,10 +867,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -735,6 +891,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -754,22 +916,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity """ _validation = { @@ -797,6 +959,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -817,22 +997,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -875,6 +1055,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -884,12 +1082,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -902,6 +1100,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -911,8 +1117,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -923,6 +1129,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -936,13 +1146,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_03_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -962,6 +1172,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.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.resource.resources.v2019_03_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -972,11 +1192,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -988,6 +1208,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1000,11 +1227,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1021,6 +1248,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1030,10 +1264,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay """ _attribute_map = { @@ -1045,6 +1279,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1053,14 +1293,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1074,6 +1314,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1084,10 +1334,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1099,6 +1349,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1109,10 +1365,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1128,6 +1384,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1136,16 +1398,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1160,6 +1422,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1175,8 +1449,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1205,6 +1479,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1218,8 +1496,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1237,6 +1515,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1245,20 +1527,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1275,6 +1557,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1298,15 +1596,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1330,6 +1628,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1343,10 +1653,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails """ @@ -1359,6 +1669,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1367,10 +1684,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1382,6 +1699,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1392,8 +1715,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1411,6 +1734,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1419,14 +1746,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1440,6 +1767,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1468,6 +1806,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1477,8 +1817,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1496,6 +1836,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1535,6 +1880,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1545,16 +1892,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1569,6 +1916,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1580,10 +1939,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1595,6 +1954,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1603,18 +1968,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1630,6 +1995,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1642,8 +2021,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1654,6 +2033,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1661,10 +2044,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1676,6 +2059,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1688,13 +2077,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] """ _validation = { @@ -1712,6 +2101,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1724,8 +2122,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1743,6 +2141,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1755,10 +2157,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount """ _validation = { @@ -1775,6 +2177,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1784,12 +2192,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1802,6 +2210,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1811,10 +2227,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1826,6 +2242,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1836,10 +2258,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1855,6 +2277,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1863,10 +2291,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1878,6 +2306,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py index aa0fb941ccb2c..c7df9b99144db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_03_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -426,6 +497,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -442,8 +515,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -463,6 +536,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -473,34 +550,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment """ _validation = { @@ -529,6 +607,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -550,29 +659,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype correlation_id: str :ivar timestamp: The timestamp of the template deployment. :vartype timestamp: ~datetime.datetime - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentExtended """ @@ -613,6 +722,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_03_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_03_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_03_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_03_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -632,11 +767,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended """ @@ -652,6 +787,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -682,6 +825,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -725,6 +870,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -736,13 +883,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -757,6 +904,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -773,10 +929,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -800,6 +956,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -819,22 +981,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity """ _validation = { @@ -871,6 +1033,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -891,22 +1071,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -958,6 +1138,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_03_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_03_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_03_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -967,12 +1165,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -989,6 +1187,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -998,8 +1204,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1012,6 +1218,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1025,13 +1235,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_03_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1054,6 +1264,16 @@ def __init__( 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.resource.resources.v2019_03_01.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.resource.resources.v2019_03_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1064,11 +1284,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1083,6 +1303,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1095,11 +1322,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1119,6 +1346,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_03_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1128,10 +1362,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay """ _attribute_map = { @@ -1146,6 +1380,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_03_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1154,14 +1394,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1180,6 +1420,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1190,10 +1440,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1208,6 +1458,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1218,10 +1474,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1240,6 +1496,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1248,16 +1510,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1278,6 +1540,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1293,8 +1567,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1325,6 +1599,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1338,8 +1616,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1359,6 +1637,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1367,20 +1649,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1405,6 +1687,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_03_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_03_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1428,15 +1726,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1465,6 +1763,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1478,10 +1788,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails """ @@ -1497,6 +1807,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1505,10 +1822,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1523,6 +1840,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1533,8 +1856,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1554,6 +1877,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1562,14 +1889,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1588,6 +1915,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1616,6 +1954,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1625,8 +1965,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1646,6 +1986,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1685,6 +2030,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1695,16 +2042,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1725,6 +2072,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1736,10 +2095,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1754,6 +2113,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1762,18 +2127,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1796,6 +2161,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1808,8 +2187,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1822,6 +2201,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1829,10 +2212,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1847,6 +2230,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1859,13 +2248,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] """ _validation = { @@ -1887,6 +2276,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1899,8 +2297,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1920,6 +2318,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_03_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1932,10 +2334,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount """ _validation = { @@ -1955,6 +2357,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_03_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1964,12 +2372,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1986,6 +2394,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -1995,10 +2411,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2013,6 +2429,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2023,10 +2445,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2045,6 +2467,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2053,10 +2481,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2071,6 +2499,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py index 20e515131352e..02799db402bcc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -37,7 +22,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -45,7 +30,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployment_operations_operations.py index d9c0b995fb9e6..47fa009b4a95c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployment_operations_operations.py @@ -5,24 +5,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +205,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -68,27 +229,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -102,8 +253,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -118,8 +272,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +283,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +327,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -206,28 +360,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -241,8 +385,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -260,8 +407,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -269,38 +418,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,6 +464,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployments_operations.py index 3d3dd3a6c2e22..96b38fde65a40 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_deployments_operations.py @@ -5,26 +5,614 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -58,24 +646,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -88,6 +668,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -108,15 +690,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -129,20 +713,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -154,8 +732,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -176,24 +756,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -203,10 +775,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -219,31 +792,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -261,8 +824,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -280,15 +846,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -299,26 +870,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -330,8 +896,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -352,26 +920,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +943,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -412,24 +973,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,6 +995,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -466,31 +1021,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -508,8 +1053,11 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -530,26 +1078,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -563,8 +1101,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -580,8 +1121,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -589,38 +1132,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -638,6 +1176,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -655,25 +1194,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -686,6 +1217,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -711,15 +1244,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -733,21 +1268,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -759,8 +1287,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -785,25 +1315,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -813,10 +1335,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -830,32 +1353,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -873,8 +1386,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -896,15 +1412,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -916,27 +1437,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -948,8 +1463,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -973,27 +1490,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1007,8 +1514,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -1037,25 +1547,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1068,6 +1570,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -1096,32 +1600,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1139,8 +1633,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -1164,27 +1661,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1198,8 +1685,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -1219,8 +1709,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1228,39 +1720,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1278,11 +1766,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -1303,26 +1793,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1336,4 +1819,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py index ae7d74397b770..2df0dfa3148fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_03_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_providers_operations.py index 48f0b7cfe69a0..4e153456777bc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resource_groups_operations.py index 9c99719bf853f..23fa302ae02ef 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -124,31 +370,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -166,8 +402,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -179,24 +417,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +439,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -225,15 +457,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -246,20 +480,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -271,8 +499,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -294,26 +524,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,8 +547,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -357,31 +580,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +608,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -420,31 +636,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -458,8 +664,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -476,8 +685,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -485,38 +696,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,6 +740,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resources_operations.py index 5d32d4e823b36..5d02a7104a3d5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -78,11 +613,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -90,41 +626,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,6 +674,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -159,29 +692,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -194,6 +719,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -215,15 +742,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -234,23 +764,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -262,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -276,29 +802,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -311,6 +829,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -334,15 +854,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -353,23 +876,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -381,8 +899,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -411,11 +931,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -423,40 +944,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -474,11 +990,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -516,26 +1034,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,10 +1057,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -566,26 +1079,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -598,6 +1105,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -626,15 +1135,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -652,24 +1163,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -681,6 +1182,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -700,34 +1202,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -746,8 +1240,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -779,15 +1276,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -803,30 +1305,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -838,6 +1331,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -857,34 +1351,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -900,8 +1386,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -933,15 +1422,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -957,30 +1451,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -992,8 +1477,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1030,29 +1517,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1066,8 +1545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1094,21 +1576,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1118,10 +1594,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1135,21 +1612,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1162,6 +1633,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1179,15 +1652,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1201,19 +1676,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1225,6 +1695,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1240,29 +1711,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1281,8 +1744,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1303,15 +1769,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1323,25 +1794,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1353,6 +1820,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1368,29 +1836,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1406,8 +1866,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1428,15 +1891,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_03_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1448,25 +1916,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1478,8 +1942,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1505,24 +1971,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1536,4 +1994,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_tags_operations.py index f825e11a96e3c..c9a570b1d6f61 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_03_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_03_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py index 9f9ff09f5bb1d..96ba8c464bde3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json index 64cc8fee0abf0..075aff5c42593 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py index b2fdb73187580..58829ec8551b0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_05_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_05_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_05_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py index 2884a826d6416..4bb5149a69f92 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py index e961ebef7bbd8..5bdbfce57a659 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_05_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_05_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_05_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_05_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_05_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_05_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_05_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_05_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployment_operations_operations.py index 1336bba413fa6..b21612f4575f7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_subscription_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -66,27 +72,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -118,8 +117,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -202,27 +201,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -236,8 +225,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -251,8 +243,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -260,37 +254,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -308,11 +298,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -338,28 +330,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -373,8 +355,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -391,8 +376,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -400,38 +387,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -449,6 +433,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployments_operations.py index b8d440c06855e..6b9762711e929 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_subscription_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_subscription_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_subscription_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request, build_validate_at_subscription_scope_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,24 +59,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -84,6 +81,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -106,15 +105,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,20 +129,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -153,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -177,24 +174,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,10 +193,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -220,31 +210,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,8 +242,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -283,15 +266,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -303,26 +291,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -334,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -358,26 +343,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -391,8 +366,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -420,24 +398,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -450,6 +420,8 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_management_group_scope( self, group_id: str, @@ -476,31 +448,21 @@ async def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -518,8 +480,11 @@ async def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -542,26 +507,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -575,8 +530,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -594,8 +552,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -603,38 +563,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -652,6 +607,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -667,24 +623,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -697,6 +645,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -716,15 +666,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -737,20 +689,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -762,8 +708,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -783,24 +731,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -810,10 +750,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -825,31 +766,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -867,8 +798,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -885,15 +819,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -904,26 +843,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -935,8 +869,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -956,26 +892,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -989,8 +915,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -1015,24 +944,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1045,6 +966,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -1068,31 +991,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1110,8 +1023,11 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -1131,26 +1047,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1164,8 +1070,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -1180,8 +1089,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1189,38 +1100,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1238,6 +1144,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1254,25 +1161,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1285,6 +1184,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -1309,15 +1210,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1331,21 +1234,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1357,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -1382,25 +1280,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1410,10 +1300,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -1426,32 +1317,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1469,8 +1350,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -1491,15 +1375,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1511,27 +1400,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1543,8 +1426,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1567,27 +1452,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1601,8 +1476,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -1630,25 +1508,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1661,6 +1531,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -1688,32 +1560,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1731,8 +1593,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -1755,27 +1620,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1789,8 +1644,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -1809,8 +1667,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1818,39 +1678,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1868,11 +1724,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -1892,26 +1750,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1925,4 +1776,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py index e4b9af285f0d4..171b2ef81f8be 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_05_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_providers_operations.py index 0a72651c1d171..258f0db0e275b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -250,28 +240,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -285,4 +264,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resource_groups_operations.py index 201d466dc424c..8a0bfa7d108e1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -118,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -172,24 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -202,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -217,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -238,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -263,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -285,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -318,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -347,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +352,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -409,31 +379,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -447,8 +407,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -464,8 +427,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -473,38 +438,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -522,6 +482,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resources_operations.py index 988e821b01388..49788298195f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -73,11 +79,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -85,41 +92,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,6 +140,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -153,29 +157,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,6 +184,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -208,15 +206,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -227,23 +228,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -255,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -268,29 +265,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -303,6 +292,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -325,15 +316,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -344,23 +338,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -372,8 +361,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -401,11 +392,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -413,40 +405,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -464,11 +451,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -505,26 +494,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,10 +517,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -554,26 +538,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -586,6 +564,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -613,15 +593,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -639,24 +621,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -668,6 +640,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -686,34 +659,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -732,8 +697,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -764,15 +732,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -788,30 +761,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -823,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -841,34 +806,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -884,8 +841,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -916,15 +876,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -940,30 +905,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -975,8 +931,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1012,29 +970,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1048,8 +998,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1075,21 +1028,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1099,10 +1046,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1115,21 +1063,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1142,6 +1084,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1158,15 +1102,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1180,19 +1126,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1204,6 +1145,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1218,29 +1160,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1259,8 +1193,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1280,15 +1217,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1300,25 +1242,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1330,6 +1268,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1344,29 +1283,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1382,8 +1313,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1403,15 +1337,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1423,25 +1362,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1453,8 +1388,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1479,24 +1416,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1510,4 +1439,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_tags_operations.py index 8f5c6ec7c08bc..9e696e57418cf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models.py index fc053e42c1ec9..11091a4118500 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -395,6 +466,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -412,8 +485,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -431,6 +504,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -441,34 +518,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment """ _validation = { @@ -489,6 +567,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -512,29 +621,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentExtended """ @@ -566,6 +675,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -586,11 +721,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ @@ -603,6 +738,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -633,6 +776,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -676,6 +821,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -687,13 +834,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -705,6 +852,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -721,10 +877,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -745,6 +901,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -764,22 +926,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity """ _validation = { @@ -807,6 +969,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -827,22 +1007,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -885,6 +1065,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -894,12 +1092,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -912,6 +1110,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -921,8 +1127,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -933,6 +1139,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -946,13 +1156,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -972,6 +1182,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.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.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -982,11 +1202,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -998,6 +1218,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1010,11 +1237,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1031,6 +1258,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1040,10 +1274,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay """ _attribute_map = { @@ -1055,6 +1289,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1063,14 +1303,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1084,6 +1324,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1094,10 +1344,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1109,6 +1359,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1119,10 +1375,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1138,6 +1394,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1146,16 +1408,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1170,6 +1432,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1185,8 +1459,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1215,6 +1489,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1228,8 +1506,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1247,6 +1525,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1255,20 +1537,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1285,6 +1567,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1308,15 +1606,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1340,6 +1638,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1353,10 +1663,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails """ @@ -1369,6 +1679,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1377,10 +1694,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1392,6 +1709,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1402,8 +1725,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1421,6 +1744,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1429,14 +1756,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1450,6 +1777,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1478,6 +1816,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1487,8 +1827,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1506,6 +1846,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1545,6 +1890,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1555,16 +1902,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1579,6 +1926,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1590,10 +1949,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1605,6 +1964,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1613,18 +1978,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1640,6 +2005,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1652,8 +2031,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1664,6 +2043,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1671,10 +2054,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1686,6 +2069,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1698,13 +2087,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] """ _validation = { @@ -1722,6 +2111,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1734,8 +2132,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1753,6 +2151,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1765,10 +2167,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount """ _validation = { @@ -1785,6 +2187,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1794,12 +2202,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1812,6 +2220,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1821,10 +2237,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1836,6 +2252,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1846,10 +2268,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1865,6 +2287,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1873,10 +2301,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1888,6 +2316,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py index 5632af08bb0b9..5d1975537932d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_05_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -430,6 +501,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -447,8 +520,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -468,6 +541,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -478,34 +555,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment """ _validation = { @@ -534,6 +612,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -557,29 +666,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentExtended """ @@ -622,6 +731,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -642,11 +777,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended """ @@ -662,6 +797,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -692,6 +835,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -735,6 +880,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -746,13 +893,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -767,6 +914,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -783,10 +939,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -810,6 +966,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -829,22 +991,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity """ _validation = { @@ -881,6 +1043,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -901,22 +1081,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -968,6 +1148,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -977,12 +1175,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -999,6 +1197,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1008,8 +1214,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1022,6 +1228,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1035,13 +1245,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1064,6 +1274,16 @@ def __init__( 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.resource.resources.v2019_05_01.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.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1074,11 +1294,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1093,6 +1313,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1105,11 +1332,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1129,6 +1356,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1138,10 +1372,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay """ _attribute_map = { @@ -1156,6 +1390,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1164,14 +1404,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1190,6 +1430,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1200,10 +1450,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1218,6 +1468,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1228,10 +1484,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1250,6 +1506,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1258,16 +1520,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1288,6 +1550,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1303,8 +1577,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1335,6 +1609,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1348,8 +1626,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1369,6 +1647,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1377,20 +1659,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1415,6 +1697,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1438,15 +1736,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1475,6 +1773,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1488,10 +1798,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails """ @@ -1507,6 +1817,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1515,10 +1832,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1533,6 +1850,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1543,8 +1866,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1564,6 +1887,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1572,14 +1899,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1598,6 +1925,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1626,6 +1964,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1635,8 +1975,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1656,6 +1996,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1695,6 +2040,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1705,16 +2052,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1735,6 +2082,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1746,10 +2105,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1764,6 +2123,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1772,18 +2137,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1806,6 +2171,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1818,8 +2197,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1832,6 +2211,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1839,10 +2222,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1857,6 +2240,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1869,13 +2258,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] """ _validation = { @@ -1897,6 +2286,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1909,8 +2307,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1930,6 +2328,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1942,10 +2344,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount """ _validation = { @@ -1965,6 +2367,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1974,12 +2382,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1996,6 +2404,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2005,10 +2421,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2023,6 +2439,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2033,10 +2455,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2055,6 +2477,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2063,10 +2491,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2081,6 +2509,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py index 20e515131352e..02799db402bcc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -37,7 +22,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -45,7 +30,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py index 2777c43d12f26..3c63f88e28a57 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py @@ -5,24 +5,258 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +279,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -71,27 +306,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +330,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -124,8 +352,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +363,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +407,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -209,27 +437,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +461,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -259,8 +480,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -268,37 +491,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -316,11 +535,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -347,28 +568,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -382,8 +593,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -401,8 +615,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -410,38 +626,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,6 +672,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployments_operations.py index ad8af33e41c03..7a8e59f54183b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployments_operations.py @@ -5,26 +5,881 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,24 +914,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,6 +936,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -112,15 +961,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,20 +985,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -159,8 +1004,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -184,24 +1031,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,10 +1050,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -228,31 +1068,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -270,8 +1100,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -292,15 +1125,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -312,26 +1150,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -343,8 +1176,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -368,26 +1203,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +1226,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -431,24 +1259,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -461,6 +1281,8 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_management_group_scope( self, group_id, # type: str @@ -488,31 +1310,21 @@ def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -530,8 +1342,11 @@ def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -555,26 +1370,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -588,8 +1393,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -608,8 +1416,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -617,38 +1427,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -666,6 +1471,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -682,24 +1488,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -712,6 +1510,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -732,15 +1532,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -753,20 +1555,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -778,8 +1574,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -800,24 +1598,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -827,10 +1617,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -843,31 +1634,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -885,8 +1666,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -904,15 +1688,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -923,26 +1712,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -954,8 +1738,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -976,26 +1762,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1009,8 +1785,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -1036,24 +1815,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1066,6 +1837,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -1090,31 +1863,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1132,8 +1895,11 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -1154,26 +1920,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1187,8 +1943,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -1204,8 +1963,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1213,38 +1974,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1262,6 +2018,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1279,25 +2036,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1310,6 +2059,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -1335,15 +2086,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1357,21 +2110,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1383,8 +2129,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -1409,25 +2157,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1437,10 +2177,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -1454,32 +2195,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1497,8 +2228,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -1520,15 +2254,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1540,27 +2279,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1572,8 +2305,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1597,27 +2332,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1631,8 +2356,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -1661,25 +2389,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1692,6 +2412,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -1720,32 +2442,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1763,8 +2475,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -1788,27 +2503,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1822,8 +2527,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -1843,8 +2551,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1852,39 +2562,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1902,11 +2608,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -1927,26 +2635,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1960,4 +2661,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py index 8c30c0595cd41..75b172e445b83 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_05_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_providers_operations.py index 85d20bee1f5d3..17e9dd64ce094 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_providers_operations.py @@ -5,24 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +198,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +219,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +242,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +267,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +290,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +312,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +321,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +365,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -258,28 +396,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,4 +420,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resource_groups_operations.py index 51e56c45c68c2..da7b28221db3d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -124,31 +370,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -166,8 +402,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -179,24 +417,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +439,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -225,15 +457,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -246,20 +480,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -271,8 +499,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -294,26 +524,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,8 +547,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -357,31 +580,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +608,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -420,31 +636,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -458,8 +664,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -476,8 +685,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -485,38 +696,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,6 +740,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resources_operations.py index 4bea93c4106a2..7c37e05ea06cd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -78,11 +613,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -90,41 +626,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,6 +674,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -159,29 +692,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -194,6 +719,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -215,15 +742,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -234,23 +764,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -262,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -276,29 +802,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -311,6 +829,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -334,15 +854,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -353,23 +876,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -381,8 +899,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -411,11 +931,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -423,40 +944,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -474,11 +990,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -516,26 +1034,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,10 +1057,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -566,26 +1079,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -598,6 +1105,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -626,15 +1135,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -652,24 +1163,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -681,6 +1182,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -700,34 +1202,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -746,8 +1240,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -779,15 +1276,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -803,30 +1305,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -838,6 +1331,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -857,34 +1351,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -900,8 +1386,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -933,15 +1422,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -957,30 +1451,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -992,8 +1477,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1030,29 +1517,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1066,8 +1545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1094,21 +1576,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1118,10 +1594,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1135,21 +1612,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1162,6 +1633,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1179,15 +1652,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1201,19 +1676,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1225,6 +1695,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1240,29 +1711,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1281,8 +1744,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1303,15 +1769,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1323,25 +1794,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1353,6 +1820,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1368,29 +1836,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1406,8 +1866,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1428,15 +1891,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1448,25 +1916,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1478,8 +1942,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1505,24 +1971,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1536,4 +1994,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_tags_operations.py index 5790251858716..a184965590a2b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py index 5ffdf9d463fc0..488874bbb94dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json index 9ab38b6690454..b49e4b338fef8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py index c3cb40173475a..d4525f0bd2e3a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_10.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_05_10.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_05_10.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_10.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_05_10.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_10.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py index bd847a3da5e6a..e8705f68c8d3f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py index 6d5d26754b9b8..8a556029ac026 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_10.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_05_10.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_05_10.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_05_10.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_05_10.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_05_10.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_05_10.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_10.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_05_10.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_10.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_05_10.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployment_operations_operations.py index bbfa511a990d2..4fff6f0fcfe80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_subscription_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -66,27 +72,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -118,8 +117,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -202,27 +201,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -236,8 +225,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -251,8 +243,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -260,37 +254,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -308,11 +298,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -338,28 +330,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -373,8 +355,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -391,8 +376,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -400,38 +387,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -449,6 +433,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployments_operations.py index a44a4478cb5e5..babf70db651f7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_subscription_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_subscription_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_subscription_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_subscription_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request, build_validate_at_subscription_scope_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,24 +59,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -84,6 +81,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -106,15 +105,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -128,20 +129,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -153,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -177,24 +174,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -204,10 +193,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -220,31 +210,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -262,8 +242,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -283,15 +266,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -303,26 +291,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -334,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -358,26 +343,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -391,8 +366,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -420,24 +398,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -450,6 +420,8 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_management_group_scope( self, group_id: str, @@ -476,31 +448,21 @@ async def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -518,8 +480,11 @@ async def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -542,26 +507,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -575,8 +530,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -594,8 +552,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -603,38 +563,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -652,6 +607,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -667,24 +623,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -697,6 +645,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -716,15 +666,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -737,20 +689,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -762,8 +708,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -783,24 +731,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -810,10 +750,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -825,31 +766,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -867,8 +798,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -885,15 +819,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -904,26 +843,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -935,8 +869,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -956,26 +892,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -989,8 +915,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -1015,24 +944,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1045,6 +966,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -1068,31 +991,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1110,8 +1023,11 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -1131,26 +1047,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1164,8 +1070,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -1180,8 +1089,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1189,38 +1100,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1238,6 +1144,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1254,25 +1161,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1285,6 +1184,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -1309,15 +1210,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1331,21 +1234,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1357,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -1382,25 +1280,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1410,10 +1300,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -1426,32 +1317,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1469,8 +1350,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -1491,15 +1375,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1511,27 +1400,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1543,8 +1426,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1567,27 +1452,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1601,8 +1476,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -1630,25 +1508,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1661,6 +1531,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -1688,32 +1560,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1731,8 +1593,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -1755,27 +1620,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1789,8 +1644,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -1809,8 +1667,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1818,39 +1678,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1868,11 +1724,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -1892,26 +1750,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1925,4 +1776,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py index 4250f7390e912..0f9dbb5ecb3da 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_05_10.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_providers_operations.py index 3f0073541ea40..5cc4768494997 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -243,7 +233,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -251,34 +242,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -296,11 +284,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -324,28 +314,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,8 +338,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -384,27 +366,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,4 +389,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resource_groups_operations.py index 39c4412d75b62..384a21d78247b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,24 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -90,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -118,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -172,24 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -202,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -217,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -238,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -263,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -285,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -318,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -347,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -385,8 +352,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -409,31 +379,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -447,8 +407,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -464,8 +427,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -473,38 +438,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -522,6 +482,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resources_operations.py index 4abae2ea7183d..9ea97a422e1cb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -73,11 +79,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -85,41 +92,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,6 +140,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -153,29 +157,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -188,6 +184,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -208,15 +206,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -227,23 +228,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -255,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -268,29 +265,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -303,6 +292,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -325,15 +316,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -344,23 +338,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -372,8 +361,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -401,11 +392,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -413,40 +405,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -464,11 +451,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -505,26 +494,20 @@ async def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -534,10 +517,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -554,26 +538,20 @@ async def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -586,6 +564,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -613,15 +593,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -639,24 +621,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -668,6 +640,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -686,34 +659,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -732,8 +697,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -764,15 +732,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -788,30 +761,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -823,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -841,34 +806,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -884,8 +841,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -916,15 +876,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -940,30 +905,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -975,8 +931,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1012,29 +970,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1048,8 +998,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1075,21 +1028,15 @@ async def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1099,10 +1046,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1115,21 +1063,15 @@ async def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1142,6 +1084,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1158,15 +1102,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1180,19 +1126,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1204,6 +1145,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1218,29 +1160,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1259,8 +1193,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1280,15 +1217,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1300,25 +1242,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1330,6 +1268,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1344,29 +1283,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1382,8 +1313,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1403,15 +1337,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1423,25 +1362,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1453,8 +1388,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1479,24 +1416,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1510,4 +1439,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_tags_operations.py index 1936091369ef5..edf6f29f21018 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,25 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -94,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -116,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -154,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -179,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -239,24 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -269,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -285,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -330,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models.py index cd35b59bb790e..5d588c3f1f45e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -395,6 +466,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -412,8 +485,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -431,6 +504,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -441,34 +518,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment """ _validation = { @@ -489,6 +567,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -512,29 +621,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentExtended """ @@ -566,6 +675,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -586,11 +721,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ @@ -603,6 +738,14 @@ def __init__( self, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -633,6 +776,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -676,6 +821,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -687,13 +834,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -705,6 +852,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -721,10 +877,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -745,6 +901,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -764,22 +926,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity """ _validation = { @@ -807,6 +969,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -827,22 +1007,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -885,6 +1065,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -894,12 +1092,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -912,6 +1110,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -921,8 +1127,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -933,6 +1139,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -946,13 +1156,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -972,6 +1182,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.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.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -982,11 +1202,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -998,6 +1218,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1010,11 +1237,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1031,6 +1258,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1040,10 +1274,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay """ _attribute_map = { @@ -1055,6 +1289,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1063,14 +1303,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1084,6 +1324,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1094,10 +1344,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1109,6 +1359,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1119,10 +1375,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1138,6 +1394,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1146,16 +1408,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1170,6 +1432,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1185,8 +1459,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1215,6 +1489,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1228,8 +1506,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1247,6 +1525,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1255,20 +1537,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1285,6 +1567,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1308,15 +1606,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1340,6 +1638,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1353,10 +1663,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails """ @@ -1369,6 +1679,13 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1377,10 +1694,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1392,6 +1709,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1402,8 +1725,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1421,6 +1744,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1429,14 +1756,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1450,6 +1777,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1478,6 +1816,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1487,8 +1827,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1506,6 +1846,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1545,6 +1890,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1555,16 +1902,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1579,6 +1926,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1590,10 +1949,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1605,6 +1964,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1613,18 +1978,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1640,6 +2005,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1652,8 +2031,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1664,6 +2043,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1671,10 +2054,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1686,6 +2069,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1698,13 +2087,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] """ _validation = { @@ -1722,6 +2111,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1734,8 +2132,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1753,6 +2151,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1765,10 +2167,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount """ _validation = { @@ -1785,6 +2187,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1794,12 +2202,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1812,6 +2220,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1821,10 +2237,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1836,6 +2252,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1846,10 +2268,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1865,6 +2287,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1873,10 +2301,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -1888,6 +2316,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py index 9586a99df71bd..bed774f041d69 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_05_10.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -430,6 +501,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -447,8 +520,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -468,6 +541,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -478,34 +555,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment """ _validation = { @@ -534,6 +612,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -557,29 +666,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentExtended """ @@ -622,6 +731,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_05_10.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_05_10.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_05_10.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -642,11 +777,11 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: Validation error. - :type error: + :ivar error: Validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended """ @@ -662,6 +797,14 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: Validation error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -692,6 +835,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -735,6 +880,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -746,13 +893,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -767,6 +914,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -783,10 +939,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -810,6 +966,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -829,22 +991,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity """ _validation = { @@ -881,6 +1043,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -901,22 +1081,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -968,6 +1148,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_05_10.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_05_10.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_05_10.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -977,12 +1175,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -999,6 +1197,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1008,8 +1214,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1022,6 +1228,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1035,13 +1245,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1064,6 +1274,16 @@ def __init__( 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.resource.resources.v2019_05_10.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.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1074,11 +1294,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1093,6 +1313,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1105,11 +1332,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1129,6 +1356,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1138,10 +1372,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay """ _attribute_map = { @@ -1156,6 +1390,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1164,14 +1404,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1190,6 +1430,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1200,10 +1450,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1218,6 +1468,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1228,10 +1484,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1250,6 +1506,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1258,16 +1520,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1288,6 +1550,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1303,8 +1577,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1335,6 +1609,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1348,8 +1626,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1369,6 +1647,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1377,20 +1659,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1415,6 +1697,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_05_10.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1438,15 +1736,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1475,6 +1773,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1488,10 +1798,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The error. - :type error: + :ivar template: The template content. + :vartype template: any + :ivar error: The error. + :vartype error: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails """ @@ -1507,6 +1817,13 @@ def __init__( error: Optional["ResourceManagementErrorWithDetails"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The error. + :paramtype error: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceManagementErrorWithDetails + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1515,10 +1832,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1533,6 +1850,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1543,8 +1866,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1564,6 +1887,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1572,14 +1899,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1598,6 +1925,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1626,6 +1964,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1635,8 +1975,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1656,6 +1996,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1695,6 +2040,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1705,16 +2052,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1735,6 +2082,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1746,10 +2105,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1764,6 +2123,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1772,18 +2137,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1806,6 +2171,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1818,8 +2197,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1832,6 +2211,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1839,10 +2222,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1857,6 +2240,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1869,13 +2258,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] """ _validation = { @@ -1897,6 +2286,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1909,8 +2307,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1930,6 +2328,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1942,10 +2344,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount """ _validation = { @@ -1965,6 +2367,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_05_10.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -1974,12 +2382,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1996,6 +2404,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2005,10 +2421,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2023,6 +2439,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2033,10 +2455,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2055,6 +2477,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2063,10 +2491,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2081,6 +2509,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py index 20e515131352e..02799db402bcc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -37,7 +22,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -45,7 +30,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py index 01fac8cf725f5..4bc7cf662a613 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py @@ -5,24 +5,258 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +279,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -71,27 +306,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +330,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -124,8 +352,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +363,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +407,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -209,27 +437,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -243,8 +461,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -259,8 +480,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -268,37 +491,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -316,11 +535,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -347,28 +568,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -382,8 +593,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -401,8 +615,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -410,38 +626,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,6 +672,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployments_operations.py index 91cf265069be3..bffc10562c6cd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployments_operations.py @@ -5,26 +5,881 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,24 +914,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,6 +936,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -112,15 +961,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -134,20 +985,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -159,8 +1004,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -184,24 +1031,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -211,10 +1050,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -228,31 +1068,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -270,8 +1100,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -292,15 +1125,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -312,26 +1150,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -343,8 +1176,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -368,26 +1203,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -401,8 +1226,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -431,24 +1259,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -461,6 +1281,8 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_management_group_scope( self, group_id, # type: str @@ -488,31 +1310,21 @@ def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -530,8 +1342,11 @@ def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -555,26 +1370,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -588,8 +1393,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -608,8 +1416,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -617,38 +1427,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -666,6 +1471,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -682,24 +1488,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -712,6 +1510,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -732,15 +1532,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -753,20 +1555,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -778,8 +1574,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -800,24 +1598,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -827,10 +1617,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -843,31 +1634,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -885,8 +1666,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -904,15 +1688,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -923,26 +1712,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -954,8 +1738,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -976,26 +1762,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1009,8 +1785,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -1036,24 +1815,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1066,6 +1837,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -1090,31 +1863,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1132,8 +1895,11 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -1154,26 +1920,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1187,8 +1943,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -1204,8 +1963,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1213,38 +1974,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1262,6 +2018,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1279,25 +2036,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1310,6 +2059,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -1335,15 +2086,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1357,21 +2110,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1383,8 +2129,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -1409,25 +2157,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1437,10 +2177,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -1454,32 +2195,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1497,8 +2228,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -1520,15 +2254,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1540,27 +2279,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1572,8 +2305,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1597,27 +2332,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1631,8 +2356,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -1661,25 +2389,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1692,6 +2412,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -1720,32 +2442,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1763,8 +2475,11 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -1788,27 +2503,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1822,8 +2527,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -1843,8 +2551,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1852,39 +2562,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1902,11 +2608,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -1927,26 +2635,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1960,4 +2661,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py index cdb3162f79f55..d38adb37b288f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_05_10.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_providers_operations.py index ae2dc64e91ba8..54a9cf76bc4a0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_providers_operations.py @@ -5,24 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +267,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +288,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +311,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +336,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +359,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +381,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +390,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +434,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -251,7 +458,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -259,34 +467,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,11 +509,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -333,28 +540,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -368,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -394,27 +593,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -428,4 +616,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resource_groups_operations.py index 91d5ac39627eb..2f02dda1a935e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resource_groups_operations.py @@ -5,26 +5,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +298,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,24 +320,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,10 +339,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -124,31 +370,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -166,8 +402,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -179,24 +417,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +439,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -225,15 +457,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -246,20 +480,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -271,8 +499,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -294,26 +524,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -327,8 +547,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -357,31 +580,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +608,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -420,31 +636,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -458,8 +664,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -476,8 +685,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -485,38 +696,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,6 +740,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resources_operations.py index 61aa3649b174e..9adf7f66310ca 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_resources_operations.py @@ -5,26 +5,560 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="HEAD", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +581,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -78,11 +613,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -90,41 +626,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,6 +674,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -159,29 +692,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -194,6 +719,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -215,15 +742,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -234,23 +764,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -262,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -276,29 +802,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -311,6 +829,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -334,15 +854,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -353,23 +876,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -381,8 +899,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -411,11 +931,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -423,40 +944,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -474,11 +990,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -516,26 +1034,20 @@ def check_existence( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -545,10 +1057,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -566,26 +1079,20 @@ def _delete_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -598,6 +1105,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -626,15 +1135,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -652,24 +1163,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -681,6 +1182,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -700,34 +1202,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -746,8 +1240,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -779,15 +1276,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -803,30 +1305,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -838,6 +1331,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -857,34 +1351,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -900,8 +1386,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -933,15 +1422,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -957,30 +1451,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -992,8 +1477,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1030,29 +1517,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1066,8 +1545,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1094,21 +1576,15 @@ def check_existence_by_id( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1118,10 +1594,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1135,21 +1612,15 @@ def _delete_by_id_initial( } error_map.update(kwargs.pop('error_map', {})) - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1162,6 +1633,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1179,15 +1652,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1201,19 +1676,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1225,6 +1695,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1240,29 +1711,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1281,8 +1744,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1303,15 +1769,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1323,25 +1794,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1353,6 +1820,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1368,29 +1836,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1406,8 +1866,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1428,15 +1891,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1448,25 +1916,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1478,8 +1942,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1505,24 +1971,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1536,4 +1994,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_tags_operations.py index 68f64b0f170a4..326064328292a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_tags_operations.py @@ -5,24 +5,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-05-10" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +213,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,25 +237,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -99,6 +260,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -122,27 +285,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -160,8 +313,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -186,26 +342,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,8 +369,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -247,24 +396,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -277,6 +418,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,7 +429,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -294,34 +438,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-10" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -339,6 +478,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py index 2c40b1dd60df2..0b0b5f7cc451c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json index 4f25238470ff7..24839f76c2b3f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py index 7b30c199bd7f7..d7bac4ea80c0f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_07_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_07_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_07_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_07_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_07_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_07_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py index 8a31601fd0384..1a448297a1e8f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py index 4f7cbdb732eb7..18691371f0cf8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_07_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_07_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_07_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_07_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_07_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_07_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_07_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_07_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_07_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_07_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_07_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployment_operations_operations.py index 92a7af95fcfd8..8a7159ebd7bc1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployments_operations.py index c112ce7d84588..2b0a9ec633668 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request, build_validate_at_scope_request, build_validate_at_subscription_scope_request, build_validate_at_tenant_scope_request, build_validate_request, build_what_if_at_subscription_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,8 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_scope( self, scope: str, @@ -482,31 +448,21 @@ async def validate_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -524,8 +480,11 @@ async def validate_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -548,26 +507,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -581,8 +530,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -600,8 +552,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -609,38 +563,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -658,6 +607,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -673,25 +623,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -704,6 +644,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -723,15 +665,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -744,19 +688,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -768,8 +707,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -789,25 +730,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -817,10 +748,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -832,30 +764,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -873,8 +795,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -891,15 +816,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -910,25 +840,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -940,8 +866,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -961,25 +889,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -993,8 +911,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +940,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1050,6 +961,8 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_tenant_scope( self, deployment_name: str, @@ -1073,30 +986,20 @@ async def validate_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_tenant_scope_request( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1114,8 +1017,11 @@ async def validate_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1135,25 +1041,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1167,8 +1063,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1183,8 +1082,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1192,34 +1093,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1237,6 +1135,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1253,26 +1152,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1285,6 +1174,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1307,15 +1198,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1329,20 +1222,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1354,8 +1241,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1378,26 +1267,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1407,10 +1286,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1423,31 +1303,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1465,8 +1335,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1486,15 +1359,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1506,26 +1384,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1537,8 +1410,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1561,26 +1436,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1594,8 +1459,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1623,26 +1491,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1655,6 +1513,8 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_management_group_scope( self, group_id: str, @@ -1681,31 +1541,21 @@ async def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1723,8 +1573,11 @@ async def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -1747,26 +1600,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1780,8 +1623,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -1799,8 +1645,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1808,38 +1656,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1857,6 +1700,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1872,26 +1716,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1904,6 +1738,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -1923,15 +1759,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1944,20 +1782,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1969,8 +1801,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -1990,26 +1824,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2019,10 +1843,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2034,31 +1859,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2076,8 +1891,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2094,15 +1912,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2113,26 +1936,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2144,8 +1962,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2165,26 +1985,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2198,8 +2008,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2224,26 +2037,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2256,6 +2059,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -2279,31 +2084,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2321,8 +2116,10 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + async def _what_if_at_subscription_scope_initial( self, deployment_name: str, @@ -2334,31 +2131,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2366,21 +2153,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2396,15 +2187,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2415,26 +2211,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2446,8 +2237,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2467,26 +2260,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2283,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2516,8 +2302,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2525,38 +2313,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2574,6 +2357,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2590,27 +2374,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2623,6 +2397,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -2647,15 +2423,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2669,21 +2447,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2695,8 +2466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -2720,27 +2493,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2750,10 +2513,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -2766,32 +2530,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2809,8 +2563,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -2831,15 +2588,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2851,27 +2613,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2883,8 +2639,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -2907,27 +2665,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2941,8 +2689,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -2970,27 +2721,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3003,6 +2744,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -3030,32 +2773,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3073,8 +2806,10 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + async def _what_if_initial( self, resource_group_name: str, @@ -3087,32 +2822,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3120,21 +2845,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3154,15 +2883,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3174,27 +2908,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3206,8 +2934,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3230,27 +2960,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3264,8 +2984,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3284,8 +3007,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3293,39 +3018,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3343,11 +3064,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3367,26 +3090,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3400,4 +3116,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py index 7302d794e0f68..50168f9850809 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_07_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_providers_operations.py index d44ceb813a41d..bf0b26d419b5b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -243,7 +233,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -251,34 +242,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -296,11 +284,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -324,28 +314,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,8 +338,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -384,27 +366,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,4 +389,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resource_groups_operations.py index 305a55c933115..feb7d27f06985 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -174,26 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -221,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -242,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -267,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -351,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -389,8 +352,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -413,31 +379,21 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ExportTemplateRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -451,8 +407,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -468,8 +427,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -477,38 +438,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -526,6 +482,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resources_operations.py index bde0acc895b8b..eb4a5034e1154 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -73,11 +79,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -85,41 +92,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,6 +140,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -153,31 +157,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -190,6 +184,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -210,15 +206,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -229,23 +228,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -257,6 +251,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -270,31 +265,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -307,6 +292,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -329,15 +316,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -348,23 +338,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -376,8 +361,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -405,11 +392,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -417,40 +405,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -468,11 +451,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -508,29 +493,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -540,10 +517,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -559,29 +537,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -594,6 +564,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -621,15 +593,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -647,24 +621,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -676,6 +640,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -694,34 +659,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -740,8 +697,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -772,15 +732,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -796,30 +761,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -831,6 +787,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -849,34 +806,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -892,8 +841,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -924,15 +876,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -948,30 +905,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -983,8 +931,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1020,29 +970,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1056,8 +998,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1082,24 +1027,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1109,10 +1046,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1124,24 +1062,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1154,6 +1084,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1170,15 +1102,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1192,19 +1126,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1216,6 +1145,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1230,29 +1160,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,8 +1193,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1292,15 +1217,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1312,25 +1242,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1342,6 +1268,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1356,29 +1283,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1394,8 +1313,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1415,15 +1337,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1435,25 +1362,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1465,8 +1388,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1491,24 +1416,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1522,4 +1439,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_tags_operations.py index 0ad3ad39c782b..4c58d19a97add 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,27 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -118,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -156,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -181,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -241,26 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -281,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -289,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -334,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models.py index 1d7b125227ac3..c5b76548af574 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -395,6 +466,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -412,8 +485,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -431,6 +504,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -441,34 +518,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment """ _validation = { @@ -489,6 +567,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -512,29 +621,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentExtended """ @@ -566,6 +675,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -586,10 +721,10 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: The deployment validation error. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ @@ -602,6 +737,13 @@ def __init__( self, **kwargs ): + """ + :keyword error: The deployment validation error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -612,10 +754,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ _validation = { @@ -631,6 +774,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -641,36 +791,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings """ @@ -693,6 +844,40 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -700,9 +885,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ @@ -714,6 +899,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -743,6 +934,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -786,6 +979,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -797,13 +992,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -815,6 +1010,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -831,10 +1035,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -855,6 +1059,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -874,22 +1084,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity """ _validation = { @@ -917,6 +1127,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -937,22 +1165,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -995,6 +1223,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1004,12 +1250,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1022,6 +1268,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1031,8 +1285,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1043,6 +1297,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1056,13 +1314,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1082,6 +1340,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.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.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1092,11 +1360,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1108,6 +1376,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1120,11 +1395,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1141,6 +1416,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1150,10 +1432,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay """ _attribute_map = { @@ -1165,6 +1447,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1173,14 +1461,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1194,6 +1482,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1204,10 +1502,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1219,6 +1517,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1229,10 +1533,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1248,6 +1552,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1256,16 +1566,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1280,6 +1590,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1295,8 +1617,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1325,6 +1647,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1338,8 +1664,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1357,6 +1683,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1365,20 +1695,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1395,6 +1725,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1418,15 +1764,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1450,6 +1796,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1463,10 +1821,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ _attribute_map = { @@ -1478,6 +1836,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1486,10 +1850,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1501,6 +1865,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1511,8 +1881,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1530,6 +1900,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1538,14 +1912,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1559,6 +1933,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1587,6 +1972,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1596,8 +1983,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1615,6 +2002,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1623,16 +2015,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1647,6 +2039,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1658,10 +2062,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1673,6 +2077,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1681,18 +2091,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1708,6 +2118,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1720,8 +2144,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1732,6 +2156,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1739,10 +2167,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1754,6 +2182,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1766,13 +2200,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] """ _validation = { @@ -1790,6 +2224,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1802,8 +2245,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1821,6 +2264,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1833,10 +2280,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount """ _validation = { @@ -1853,6 +2300,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1862,12 +2315,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1880,6 +2333,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1889,10 +2350,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1904,6 +2365,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1914,10 +2381,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1933,6 +2400,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1943,18 +2416,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -1974,6 +2447,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -1985,12 +2472,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] """ _attribute_map = { @@ -2003,6 +2490,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2014,18 +2509,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -2045,6 +2540,21 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] @@ -2056,10 +2566,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2071,6 +2581,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py index 4e0a77e28e447..da30e27da1c21 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_07_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -430,6 +501,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -447,8 +520,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -468,6 +541,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -478,34 +555,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment """ _validation = { @@ -534,6 +612,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -557,29 +666,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentExtended """ @@ -622,6 +731,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_07_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -642,10 +777,10 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: The deployment validation error. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended """ @@ -661,6 +796,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: The deployment validation error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -671,10 +813,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ _validation = { @@ -693,6 +836,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -703,36 +853,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings """ @@ -764,6 +915,40 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_07_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_07_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) self.what_if_settings = what_if_settings @@ -771,9 +956,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ @@ -787,6 +972,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -816,6 +1007,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -859,6 +1052,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -870,13 +1065,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -891,6 +1086,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -907,10 +1111,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -934,6 +1138,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -953,22 +1163,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity """ _validation = { @@ -1005,6 +1215,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1025,22 +1253,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1092,6 +1320,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_07_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_07_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_07_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1101,12 +1347,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1123,6 +1369,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1132,8 +1386,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1146,6 +1400,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1159,13 +1417,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1188,6 +1446,16 @@ def __init__( 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.resource.resources.v2019_07_01.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.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1198,11 +1466,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1217,6 +1485,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1229,11 +1504,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1253,6 +1528,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1262,10 +1544,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay """ _attribute_map = { @@ -1280,6 +1562,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1288,14 +1576,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1314,6 +1602,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1324,10 +1622,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1342,6 +1640,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1352,10 +1656,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1374,6 +1678,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1382,16 +1692,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1412,6 +1722,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1427,8 +1749,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1459,6 +1781,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1472,8 +1798,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1493,6 +1819,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1501,20 +1831,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1539,6 +1869,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_07_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1562,15 +1908,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1599,6 +1945,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1612,10 +1970,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ _attribute_map = { @@ -1630,6 +1988,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1638,10 +2002,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1656,6 +2020,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1666,8 +2036,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1687,6 +2057,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1695,14 +2069,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1721,6 +2095,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1749,6 +2134,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1758,8 +2145,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1779,6 +2166,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1787,16 +2179,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1817,6 +2209,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1828,10 +2232,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1846,6 +2250,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1854,18 +2264,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1888,6 +2298,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1900,8 +2324,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1914,6 +2338,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1921,10 +2349,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1939,6 +2367,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1951,13 +2385,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] """ _validation = { @@ -1979,6 +2413,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1991,8 +2434,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2012,6 +2455,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2024,10 +2471,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount """ _validation = { @@ -2047,6 +2494,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_07_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2056,12 +2509,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2078,6 +2531,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2087,10 +2548,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2105,6 +2566,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2115,10 +2582,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2137,6 +2604,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2147,18 +2620,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -2184,6 +2657,20 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2195,12 +2682,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] """ _attribute_map = { @@ -2217,6 +2704,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2228,18 +2723,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -2265,6 +2760,21 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_07_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type @@ -2276,10 +2786,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2294,6 +2804,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py index a7d48d7672c73..137526fd26afc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -49,7 +34,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -60,7 +45,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -68,7 +53,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -84,7 +69,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -93,7 +78,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py index c59d7776ab744..1548e8c3f3ea1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployments_operations.py index 5a8d707e6735b..38ebb5f2eac08 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployments_operations.py @@ -5,26 +5,1563 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, '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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1596,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1618,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1643,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1667,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -161,8 +1686,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1713,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1732,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1750,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1782,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1807,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1832,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -347,8 +1858,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1885,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1908,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +1941,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +1963,8 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_scope( self, scope, # type: str @@ -494,31 +1992,21 @@ def validate_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -536,8 +2024,11 @@ def validate_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -561,26 +2052,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -594,8 +2075,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -614,8 +2098,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -623,38 +2109,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -672,6 +2153,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -688,25 +2170,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -719,6 +2191,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -739,15 +2213,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -760,19 +2236,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -784,8 +2255,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -806,25 +2279,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -834,10 +2297,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -850,30 +2314,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -891,8 +2345,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -910,15 +2367,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -929,25 +2391,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -959,8 +2417,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -981,25 +2441,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1013,8 +2463,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2493,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,6 +2514,8 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_tenant_scope( self, deployment_name, # type: str @@ -1095,30 +2540,20 @@ def validate_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_tenant_scope_request( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1136,8 +2571,11 @@ def validate_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1158,25 +2596,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1190,8 +2618,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1207,8 +2638,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1216,34 +2649,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1261,6 +2691,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1278,26 +2709,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1310,6 +2731,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1333,15 +2756,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1355,20 +2780,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1380,8 +2799,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1405,26 +2826,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1434,10 +2845,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1451,31 +2863,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1493,8 +2895,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1515,15 +2920,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1535,26 +2945,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1566,8 +2971,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1591,26 +2998,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1624,8 +3021,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1654,26 +3054,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1686,6 +3076,8 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_management_group_scope( self, group_id, # type: str @@ -1713,31 +3105,21 @@ def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1755,8 +3137,11 @@ def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -1780,26 +3165,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1813,8 +3188,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -1833,8 +3211,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1842,38 +3222,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1891,6 +3266,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1907,26 +3283,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1939,6 +3305,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -1959,15 +3327,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1980,20 +3350,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2005,8 +3369,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2027,26 +3393,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2056,10 +3412,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2072,31 +3429,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2114,8 +3461,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2133,15 +3483,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2152,26 +3507,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2183,8 +3533,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2205,26 +3557,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2238,8 +3580,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2265,26 +3610,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2297,6 +3632,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -2321,31 +3658,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2363,8 +3690,10 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + def _what_if_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2377,31 +3706,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2409,21 +3728,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2440,15 +3763,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2459,26 +3787,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2490,8 +3813,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -2512,26 +3837,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3860,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -2562,8 +3880,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2571,38 +3891,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2620,6 +3935,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2637,27 +3953,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2670,6 +3976,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -2695,15 +4003,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2717,21 +4027,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2743,8 +4046,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -2769,27 +4074,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2799,10 +4094,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -2816,32 +4112,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2859,8 +4145,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -2882,15 +4171,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2902,27 +4196,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2934,8 +4222,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -2959,27 +4249,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2993,8 +4273,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3023,27 +4306,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3056,6 +4329,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -3084,32 +4359,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3127,8 +4392,10 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + def _what_if_initial( self, resource_group_name, # type: str @@ -3142,32 +4409,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3175,21 +4432,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3210,15 +4471,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3230,27 +4496,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3262,8 +4522,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3287,27 +4549,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3321,8 +4573,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3342,8 +4597,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3351,39 +4608,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3401,11 +4654,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3426,26 +4681,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3459,4 +4707,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py index efb76119031af..923c2aa9a6b38 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_07_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_providers_operations.py index 3cfc8d08aa21d..2eaada50906e0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_providers_operations.py @@ -5,24 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +267,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +288,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +311,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +336,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +359,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +381,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +390,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +434,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -251,7 +458,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -259,34 +467,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,11 +509,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -333,28 +540,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -368,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -394,27 +593,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -428,4 +616,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resource_groups_operations.py index 9347c907ca894..bb1fa9c9f469d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resource_groups_operations.py @@ -5,26 +5,289 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +310,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +332,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +351,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +382,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroup') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +414,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -181,26 +429,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,6 +451,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -229,15 +469,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -250,20 +492,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -275,8 +511,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -298,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -361,31 +592,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,8 +620,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -424,31 +648,21 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ExportTemplateRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_template_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -462,8 +676,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -480,8 +697,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -489,38 +708,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -538,6 +752,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resources_operations.py index f10a356686f4f..f90f2d1b05f96 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -78,11 +641,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -90,41 +654,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,6 +702,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -159,31 +720,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -196,6 +747,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -217,15 +770,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -236,23 +792,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -264,6 +815,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -278,31 +830,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -315,6 +857,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -338,15 +882,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -357,23 +904,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -385,8 +927,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -415,11 +959,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -427,40 +972,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -478,11 +1018,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -519,29 +1061,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,10 +1085,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -571,29 +1106,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -606,6 +1133,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -634,15 +1163,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -660,24 +1191,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -689,6 +1210,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -708,34 +1230,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -754,8 +1268,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -787,15 +1304,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -811,30 +1333,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -846,6 +1359,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -865,34 +1379,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -908,8 +1414,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -941,15 +1450,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -965,30 +1479,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1000,8 +1505,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1038,29 +1545,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1074,8 +1573,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1101,24 +1603,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1128,10 +1622,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1144,24 +1639,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1174,6 +1661,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1191,15 +1680,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1213,19 +1704,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1237,6 +1723,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1252,29 +1739,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1293,8 +1772,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1315,15 +1797,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1335,25 +1822,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1365,6 +1848,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1380,29 +1864,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1418,8 +1894,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1440,15 +1919,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1460,25 +1944,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1490,8 +1970,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1517,24 +1999,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1548,4 +2022,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_tags_operations.py index 7a91be3ead2a6..c6a72df0cf2bd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_tags_operations.py @@ -5,24 +5,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +225,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,27 +249,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,6 +272,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -124,27 +297,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +325,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -188,26 +354,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,8 +381,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -249,26 +408,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,6 +430,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -290,7 +441,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -298,34 +450,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -343,6 +490,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py index 1724d52bf6d58..e85b890216713 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json index 3be420b889855..d780ded755163 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py index 6e69c0942130c..6060ee642174a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_08_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_08_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_08_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_08_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_08_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_08_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py index 06156dc9a1d9e..b7d607af1ce2e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py index c88b5cec757cb..0245b2a679cef 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_08_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_08_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_08_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_08_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_08_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_08_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_08_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_08_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_08_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_08_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_08_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployment_operations_operations.py index 8f772af9d40dd..2be379ef60dd1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployments_operations.py index 48380695e5bc4..f4e0c98b58bb9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request, build_validate_at_scope_request, build_validate_at_subscription_scope_request, build_validate_at_tenant_scope_request, build_validate_request, build_what_if_at_subscription_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,8 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_scope( self, scope: str, @@ -482,31 +448,21 @@ async def validate_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -524,8 +480,11 @@ async def validate_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -548,26 +507,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -581,8 +530,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -600,8 +552,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -609,38 +563,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -658,6 +607,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -673,25 +623,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -704,6 +644,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -723,15 +665,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -744,19 +688,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -768,8 +707,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -789,25 +730,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -817,10 +748,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -832,30 +764,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -873,8 +795,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -891,15 +816,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -910,25 +840,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -940,8 +866,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -961,25 +889,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -993,8 +911,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +940,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1050,6 +961,8 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_tenant_scope( self, deployment_name: str, @@ -1073,30 +986,20 @@ async def validate_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1114,8 +1017,11 @@ async def validate_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1135,25 +1041,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1167,8 +1063,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1183,8 +1082,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1192,34 +1093,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1237,6 +1135,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1253,26 +1152,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1285,6 +1174,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1307,15 +1198,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1329,20 +1222,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1354,8 +1241,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1378,26 +1267,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1407,10 +1286,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1423,31 +1303,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1465,8 +1335,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1486,15 +1359,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1506,26 +1384,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1537,8 +1410,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1561,26 +1436,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1594,8 +1459,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1623,26 +1491,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1655,6 +1513,8 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_management_group_scope( self, group_id: str, @@ -1681,31 +1541,21 @@ async def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1723,8 +1573,11 @@ async def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -1747,26 +1600,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1780,8 +1623,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -1799,8 +1645,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1808,38 +1656,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1857,6 +1700,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1872,26 +1716,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1904,6 +1738,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -1923,15 +1759,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1944,20 +1782,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -1969,8 +1801,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -1990,26 +1824,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2019,10 +1843,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2034,31 +1859,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2076,8 +1891,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2094,15 +1912,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2113,26 +1936,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2144,8 +1962,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2165,26 +1985,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2198,8 +2008,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2224,26 +2037,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2256,6 +2059,8 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate_at_subscription_scope( self, deployment_name: str, @@ -2279,31 +2084,21 @@ async def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2321,8 +2116,10 @@ async def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + async def _what_if_at_subscription_scope_initial( self, deployment_name: str, @@ -2334,31 +2131,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2366,21 +2153,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2396,15 +2187,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2415,26 +2211,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2446,8 +2237,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2467,26 +2260,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2283,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2516,8 +2302,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2525,38 +2313,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2574,6 +2357,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2590,27 +2374,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2623,6 +2397,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -2647,15 +2423,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2669,21 +2447,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2695,8 +2466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -2720,27 +2493,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2750,10 +2513,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -2766,32 +2530,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2809,8 +2563,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -2831,15 +2588,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2851,27 +2613,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2883,8 +2639,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -2907,27 +2665,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2941,8 +2689,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -2970,27 +2721,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3003,6 +2744,8 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace_async async def validate( self, resource_group_name: str, @@ -3030,32 +2773,22 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3073,8 +2806,10 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + async def _what_if_initial( self, resource_group_name: str, @@ -3087,32 +2822,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3120,21 +2845,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3154,15 +2883,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3174,27 +2908,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3206,8 +2934,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3230,27 +2960,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3264,8 +2984,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3284,8 +3007,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3293,39 +3018,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3343,11 +3064,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3367,26 +3090,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3400,4 +3116,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py index 3401b69cc122b..5a9bb9881dd20 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_08_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_providers_operations.py index d85a6781a042a..05a412b4bae37 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -243,7 +233,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -251,34 +242,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -296,11 +284,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -324,28 +314,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,8 +338,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -384,27 +366,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,4 +389,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resource_groups_operations.py index 48ba48eec475e..1eb9efab678e1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -174,26 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -221,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -242,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -267,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -351,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -389,8 +352,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -402,31 +367,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,8 +397,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -458,15 +416,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -477,26 +440,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -508,8 +466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -525,8 +485,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -534,38 +496,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -583,6 +540,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resources_operations.py index dbab2e6b07e58..a4d561f55b3fb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,11 +394,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -419,40 +407,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,11 +453,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -510,29 +495,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -542,10 +519,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -561,29 +539,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +566,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -623,15 +595,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -649,24 +623,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -678,6 +642,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -696,34 +661,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +699,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -774,15 +734,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,30 +763,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -833,6 +789,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -851,34 +808,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -894,8 +843,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -926,15 +878,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -950,30 +907,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -985,8 +933,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1022,29 +972,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1058,8 +1000,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1084,24 +1029,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1111,10 +1048,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1126,24 +1064,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1156,6 +1086,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1172,15 +1104,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1194,19 +1128,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1218,6 +1147,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1232,29 +1162,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1273,8 +1195,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1294,15 +1219,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1314,25 +1244,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1344,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1358,29 +1285,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1396,8 +1315,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1417,15 +1339,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1437,25 +1364,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1467,8 +1390,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1493,24 +1418,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1524,4 +1441,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_tags_operations.py index 3ab6e1d34e9f8..a7e9e809b4067 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_request, build_create_or_update_value_request, build_delete_request, build_delete_value_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -63,27 +69,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,6 +92,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -118,27 +116,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -156,8 +144,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -181,26 +172,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -218,8 +199,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -241,26 +225,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -273,6 +247,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -281,7 +257,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -289,34 +266,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -334,6 +306,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py index 0001b121e04aa..8c2a162e4fae2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models.py @@ -12,10 +12,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -35,10 +41,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] """ _attribute_map = { @@ -50,6 +56,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -58,12 +70,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -76,6 +88,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -107,6 +127,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -115,13 +137,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -132,6 +154,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -139,14 +170,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -160,6 +191,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -172,10 +213,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -191,6 +232,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -199,8 +246,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -211,6 +258,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -226,10 +277,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ @@ -251,6 +302,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -262,8 +320,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -274,6 +332,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -283,8 +345,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -302,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -316,8 +382,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationProperties """ @@ -336,6 +402,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -395,6 +466,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -412,8 +485,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -431,6 +504,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -441,34 +518,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment """ _validation = { @@ -489,6 +567,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -512,29 +621,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentExtended """ @@ -566,6 +675,32 @@ def __init__( self, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -586,10 +721,10 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: The deployment validation error. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ @@ -602,6 +737,13 @@ def __init__( self, **kwargs ): + """ + :keyword error: The deployment validation error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) @@ -612,10 +754,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ _validation = { @@ -631,6 +774,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -641,36 +791,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings """ @@ -693,6 +844,40 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -700,9 +885,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ @@ -714,6 +899,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -743,6 +934,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -786,6 +979,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -797,13 +992,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -815,6 +1010,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -831,10 +1035,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -855,6 +1059,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -874,22 +1084,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity """ _validation = { @@ -917,6 +1127,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -937,22 +1165,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -995,6 +1223,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1004,12 +1250,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1022,6 +1268,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1031,8 +1285,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1043,6 +1297,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1056,13 +1314,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1082,6 +1340,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.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.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1092,11 +1360,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1108,6 +1376,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1120,11 +1395,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1141,6 +1416,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1150,10 +1432,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay """ _attribute_map = { @@ -1165,6 +1447,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1173,14 +1461,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1194,6 +1482,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1204,10 +1502,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1219,6 +1517,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1229,10 +1533,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1248,6 +1552,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1256,16 +1566,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1280,6 +1590,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1295,8 +1617,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1325,6 +1647,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1338,8 +1664,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1357,6 +1683,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1365,20 +1695,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1395,6 +1725,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1418,15 +1764,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1450,6 +1796,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1463,10 +1821,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ _attribute_map = { @@ -1478,6 +1836,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1486,10 +1850,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1501,6 +1865,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1511,8 +1881,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1530,6 +1900,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1538,14 +1912,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1559,6 +1933,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1587,6 +1972,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1596,8 +1983,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1615,6 +2002,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1623,16 +2015,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1647,6 +2039,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1658,10 +2062,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1673,6 +2077,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1683,10 +2093,10 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -1703,6 +2113,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -1711,18 +2127,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1738,6 +2154,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1750,8 +2180,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1762,6 +2192,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1769,10 +2203,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1784,6 +2218,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1796,13 +2236,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] """ _validation = { @@ -1820,6 +2260,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1832,8 +2281,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1851,6 +2300,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1863,10 +2316,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount """ _validation = { @@ -1883,6 +2336,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -1892,12 +2351,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -1910,6 +2369,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -1919,10 +2386,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -1934,6 +2401,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -1944,10 +2417,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1963,6 +2436,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1973,18 +2452,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -2004,6 +2483,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2015,12 +2508,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] """ _attribute_map = { @@ -2033,6 +2526,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2044,18 +2545,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -2075,6 +2576,21 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] @@ -2086,10 +2602,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2101,6 +2617,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py index 2e1c83b01a740..11f8ede790079 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_models_py3.py @@ -16,10 +16,10 @@ class AliasPathType(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( api_versions: Optional[List[str]] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + """ super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -42,10 +48,10 @@ def __init__( class AliasType(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] """ _attribute_map = { @@ -60,6 +66,12 @@ def __init__( paths: Optional[List["AliasPathType"]] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] + """ super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths @@ -68,12 +80,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -90,6 +102,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -121,6 +141,8 @@ def __init__( self, **kwargs ): + """ + """ super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -129,13 +151,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -148,6 +170,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -155,14 +186,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -181,6 +212,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_08_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -193,10 +234,10 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -215,6 +256,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -223,8 +270,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -237,6 +284,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -252,10 +303,10 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ @@ -280,6 +331,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +349,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -305,6 +363,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -314,8 +376,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -335,6 +397,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -349,8 +415,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationProperties """ @@ -371,6 +437,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -430,6 +501,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -447,8 +520,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -468,6 +541,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -478,34 +555,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment """ _validation = { @@ -534,6 +612,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -557,29 +666,29 @@ class DeploymentPropertiesExtended(msrest.serialization.Model): :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str - :param outputs: Key/value pairs that represent deployment output. - :type outputs: any - :param providers: The list of resource providers needed for the deployment. - :type providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] - :param dependencies: The list of deployment dependencies. - :type dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] - :param template: The template content. Use only one of Template or TemplateLink. - :type template: any - :param template_link: The URI referencing the template. Use only one of Template or + :ivar outputs: Key/value pairs that represent deployment output. + :vartype outputs: any + :ivar providers: The list of resource providers needed for the deployment. + :vartype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :ivar dependencies: The list of deployment dependencies. + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] + :ivar template: The template content. Use only one of Template or TemplateLink. + :vartype template: any + :ivar template_link: The URI referencing the template. Use only one of Template or TemplateLink. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Deployment parameters. Use only one of Parameters or ParametersLink. - :type parameters: any - :param parameters_link: The URI referencing the parameters. Use only one of Parameters or + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :vartype parameters: any + :ivar parameters_link: The URI referencing the parameters. Use only one of Parameters or ParametersLink. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: The deployment mode. Possible values are Incremental and Complete. Possible values + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentExtended """ @@ -622,6 +731,32 @@ def __init__( on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, **kwargs ): + """ + :keyword outputs: Key/value pairs that represent deployment output. + :paramtype outputs: any + :keyword providers: The list of resource providers needed for the deployment. + :paramtype providers: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :keyword dependencies: The list of deployment dependencies. + :paramtype dependencies: list[~azure.mgmt.resource.resources.v2019_08_01.models.Dependency] + :keyword template: The template content. Use only one of Template or TemplateLink. + :paramtype template: any + :keyword template_link: The URI referencing the template. Use only one of Template or + TemplateLink. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Deployment parameters. Use only one of Parameters or ParametersLink. + :paramtype parameters: any + :keyword parameters_link: The URI referencing the parameters. Use only one of Parameters or + ParametersLink. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: The deployment mode. Possible values are Incremental and Complete. Possible + values include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentExtended + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -642,10 +777,10 @@ def __init__( class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - :param error: The deployment validation error. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar error: The deployment validation error. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended """ @@ -661,6 +796,13 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword error: The deployment validation error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties @@ -671,10 +813,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ _validation = { @@ -693,6 +836,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -703,36 +853,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings """ @@ -764,6 +915,40 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_08_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_08_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) self.what_if_settings = what_if_settings @@ -771,9 +956,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ @@ -787,6 +972,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -816,6 +1007,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -859,6 +1052,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -870,13 +1065,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -891,6 +1086,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -907,10 +1111,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -934,6 +1138,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -953,22 +1163,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity """ _validation = { @@ -1005,6 +1215,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1025,22 +1253,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1092,6 +1320,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_08_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_08_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_08_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1101,12 +1347,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1123,6 +1369,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1132,8 +1386,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1146,6 +1400,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1159,13 +1417,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -1188,6 +1446,16 @@ def __init__( 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.resource.resources.v2019_08_01.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.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1198,11 +1466,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1217,6 +1485,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1229,11 +1504,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1253,6 +1528,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1262,10 +1544,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay """ _attribute_map = { @@ -1280,6 +1562,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1288,14 +1576,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1314,6 +1602,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1324,10 +1622,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1342,6 +1640,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1352,10 +1656,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1374,6 +1678,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1382,16 +1692,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1412,6 +1722,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1427,8 +1749,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1459,6 +1781,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1472,8 +1798,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1493,6 +1819,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1501,20 +1831,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1539,6 +1869,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_08_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1562,15 +1908,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1599,6 +1945,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1612,10 +1970,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ _attribute_map = { @@ -1630,6 +1988,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1638,10 +2002,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1656,6 +2020,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1666,8 +2036,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1687,6 +2057,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1695,14 +2069,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1721,6 +2095,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1749,6 +2134,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1758,8 +2145,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1779,6 +2166,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1787,16 +2179,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1817,6 +2209,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1828,10 +2232,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1846,6 +2250,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1856,10 +2266,10 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -1879,6 +2289,12 @@ def __init__( properties: "DeploymentProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -1887,18 +2303,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1921,6 +2337,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1933,8 +2363,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1947,6 +2377,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -1954,10 +2388,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1972,6 +2406,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -1984,13 +2424,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] """ _validation = { @@ -2012,6 +2452,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2024,8 +2473,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2045,6 +2494,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2057,10 +2510,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount """ _validation = { @@ -2080,6 +2533,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_08_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2089,12 +2548,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2111,6 +2570,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2120,10 +2587,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2138,6 +2605,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2148,10 +2621,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2170,6 +2643,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2180,18 +2659,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -2217,6 +2696,20 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2228,12 +2721,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] """ _attribute_map = { @@ -2250,6 +2743,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2261,18 +2762,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -2298,6 +2799,21 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_08_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type @@ -2309,10 +2825,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2327,6 +2843,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py index a7d48d7672c73..137526fd26afc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -49,7 +34,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -60,7 +45,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -68,7 +53,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -84,7 +69,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -93,7 +78,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py index e3447fe5b435a..9a9569a9b1d72 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py index 5b726ea983ef1..686acfc875643 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployments_operations.py @@ -5,26 +5,1563 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, '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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1596,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1618,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1643,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1667,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -161,8 +1686,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1713,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1732,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1750,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1782,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1807,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1832,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -347,8 +1858,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1885,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1908,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +1941,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +1963,8 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_scope( self, scope, # type: str @@ -494,31 +1992,21 @@ def validate_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -536,8 +2024,11 @@ def validate_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -561,26 +2052,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -594,8 +2075,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -614,8 +2098,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -623,38 +2109,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -672,6 +2153,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -688,25 +2170,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -719,6 +2191,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -739,15 +2213,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -760,19 +2236,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -784,8 +2255,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -806,25 +2279,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -834,10 +2297,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -850,30 +2314,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -891,8 +2345,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -910,15 +2367,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -929,25 +2391,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -959,8 +2417,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -981,25 +2441,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1013,8 +2463,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2493,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1071,6 +2514,8 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_tenant_scope( self, deployment_name, # type: str @@ -1095,30 +2540,20 @@ def validate_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1136,8 +2571,11 @@ def validate_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1158,25 +2596,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1190,8 +2618,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1207,8 +2638,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1216,34 +2649,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1261,6 +2691,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1278,26 +2709,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1310,6 +2731,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1333,15 +2756,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1355,20 +2780,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1380,8 +2799,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1405,26 +2826,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1434,10 +2845,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1451,31 +2863,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1493,8 +2895,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1515,15 +2920,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1535,26 +2945,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1566,8 +2971,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1591,26 +2998,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1624,8 +3021,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1654,26 +3054,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1686,6 +3076,8 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_management_group_scope( self, group_id, # type: str @@ -1713,31 +3105,21 @@ def validate_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self.validate_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1755,8 +3137,11 @@ def validate_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -1780,26 +3165,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1813,8 +3188,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -1833,8 +3211,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1842,38 +3222,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1891,6 +3266,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1907,26 +3283,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1939,6 +3305,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -1959,15 +3327,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1980,20 +3350,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2005,8 +3369,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2027,26 +3393,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2056,10 +3412,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2072,31 +3429,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2114,8 +3461,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2133,15 +3483,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2152,26 +3507,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2183,8 +3533,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2205,26 +3557,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2238,8 +3580,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2265,26 +3610,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2297,6 +3632,8 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate_at_subscription_scope( self, deployment_name, # type: str @@ -2321,31 +3658,21 @@ def validate_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2363,8 +3690,10 @@ def validate_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + def _what_if_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2377,31 +3706,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2409,21 +3728,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2440,15 +3763,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2459,26 +3787,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2490,8 +3813,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -2512,26 +3837,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3860,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -2562,8 +3880,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2571,38 +3891,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2620,6 +3935,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2637,27 +3953,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2670,6 +3976,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -2695,15 +4003,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2717,21 +4027,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2743,8 +4046,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -2769,27 +4074,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2799,10 +4094,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -2816,32 +4112,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2859,8 +4145,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -2882,15 +4171,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2902,27 +4196,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2934,8 +4222,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -2959,27 +4249,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2993,8 +4273,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3023,27 +4306,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3056,6 +4329,8 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + @distributed_trace def validate( self, resource_group_name, # type: str @@ -3084,32 +4359,22 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3127,8 +4392,10 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + def _what_if_initial( self, resource_group_name, # type: str @@ -3142,32 +4409,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeploymentWhatIf') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3175,21 +4432,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3210,15 +4471,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3230,27 +4496,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3262,8 +4522,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3287,27 +4549,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3321,8 +4573,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3342,8 +4597,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3351,39 +4608,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3401,11 +4654,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3426,26 +4681,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3459,4 +4707,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py index 0a68b12d204db..3ff8d73a2a97c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_08_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_providers_operations.py index 29b54623ec5c5..63fc04445b5bf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_providers_operations.py @@ -5,24 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +267,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +288,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +311,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +336,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +359,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +381,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +390,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +434,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -251,7 +458,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -259,34 +467,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,11 +509,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -333,28 +540,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -368,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -394,27 +593,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -428,4 +616,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resource_groups_operations.py index e3e6937658e50..96dfc8002440b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resource_groups_operations.py @@ -5,26 +5,289 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +310,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +332,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +351,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +382,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +414,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -181,26 +429,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,6 +451,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -229,15 +469,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -250,20 +492,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -275,8 +511,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -298,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -361,31 +592,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,8 +620,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -413,31 +636,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -453,8 +666,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -470,15 +686,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -489,26 +710,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -520,8 +736,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -538,8 +756,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -547,38 +767,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -596,6 +811,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resources_operations.py index 355d7c33a40e7..249d1f4fe80b9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,11 +961,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +974,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +1020,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -521,29 +1063,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -553,10 +1087,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -573,29 +1108,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,6 +1135,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -636,15 +1165,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -662,24 +1193,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -691,6 +1212,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -710,34 +1232,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -756,8 +1270,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -789,15 +1306,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -813,30 +1335,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -848,6 +1361,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -867,34 +1381,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -910,8 +1416,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -943,15 +1452,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -967,30 +1481,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1002,8 +1507,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1040,29 +1547,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1076,8 +1575,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1103,24 +1605,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,10 +1624,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1146,24 +1641,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1176,6 +1663,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1193,15 +1682,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1215,19 +1706,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1239,6 +1725,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1254,29 +1741,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1295,8 +1774,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1317,15 +1799,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1337,25 +1824,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1367,6 +1850,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1382,29 +1866,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1420,8 +1896,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1442,15 +1921,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1462,25 +1946,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1492,8 +1972,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1519,24 +2001,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,4 +2024,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_tags_operations.py index 0daf2ec09ebc0..13c00e956ae2f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_tags_operations.py @@ -5,24 +5,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +225,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -68,27 +249,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,6 +272,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -124,27 +297,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +325,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -188,26 +354,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -225,8 +381,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -249,26 +408,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -281,6 +430,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -290,7 +441,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -298,34 +450,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -343,6 +490,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py index 2245ae3b6a5ec..692b2bcdaf7f5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json index 9296b15204acf..62f6a94b88dc9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py index 0f64786e6153d..705af5373a596 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_10_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_10_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_10_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_10_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_10_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_10_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py index e0ba89f1bfde8..bbfddf4690c54 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py index 6ed7c7dcafdbc..5cef00a3120dc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_10_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2019_10_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2019_10_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2019_10_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2019_10_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2019_10_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2019_10_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2019_10_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2019_10_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_10_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2019_10_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployment_operations_operations.py index 8ccaec18d4992..dba09d0435601 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployments_operations.py index f67b25664d5e4..e8897ee479860 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request_initial, build_validate_at_scope_request_initial, build_validate_at_subscription_scope_request_initial, build_validate_at_tenant_scope_request_initial, build_validate_request_initial, build_what_if_at_management_group_scope_request_initial, build_what_if_at_subscription_scope_request_initial, build_what_if_at_tenant_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,7 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_scope_initial( self, scope: str, @@ -468,31 +433,21 @@ async def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -511,8 +466,11 @@ async def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_scope( self, scope: str, @@ -531,15 +489,20 @@ async def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -551,26 +514,21 @@ async def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -582,8 +540,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -606,26 +566,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -639,8 +589,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -658,8 +611,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -667,38 +622,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -716,6 +666,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -731,25 +682,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,6 +703,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -781,15 +724,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -802,19 +747,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -826,8 +766,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -847,25 +789,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,10 +807,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -890,30 +823,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,8 +854,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -949,15 +875,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -968,25 +899,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -998,8 +925,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +948,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1051,8 +970,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1077,25 +999,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1108,6 +1020,7 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_tenant_scope_initial( self, deployment_name: str, @@ -1119,30 +1032,20 @@ async def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1161,8 +1064,11 @@ async def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_tenant_scope( self, deployment_name: str, @@ -1178,15 +1084,20 @@ async def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1197,25 +1108,21 @@ async def begin_validate_at_tenant_scope( raw_result = await self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1227,6 +1134,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_tenant_scope_initial( @@ -1240,30 +1148,20 @@ async def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,21 +1169,25 @@ async def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_tenant_scope( self, deployment_name: str, @@ -1301,15 +1203,20 @@ async def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1320,25 +1227,21 @@ async def begin_what_if_at_tenant_scope( raw_result = await self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1350,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1371,25 +1276,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1403,8 +1298,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1419,8 +1317,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1428,34 +1328,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1473,6 +1370,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1489,26 +1387,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1521,6 +1409,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1543,15 +1433,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1565,20 +1457,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1590,8 +1476,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1614,26 +1502,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1643,10 +1521,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1659,31 +1538,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1701,8 +1570,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1722,15 +1594,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1742,26 +1619,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1773,8 +1645,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1797,26 +1671,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1830,8 +1694,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1859,26 +1726,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1891,6 +1748,7 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_management_group_scope_initial( self, group_id: str, @@ -1903,31 +1761,21 @@ async def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1946,8 +1794,11 @@ async def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_management_group_scope( self, group_id: str, @@ -1966,15 +1817,20 @@ async def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1986,26 +1842,21 @@ async def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2017,6 +1868,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_management_group_scope_initial( @@ -2031,31 +1883,21 @@ async def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2063,21 +1905,25 @@ async def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_management_group_scope( self, group_id: str, @@ -2096,15 +1942,20 @@ async def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2116,26 +1967,21 @@ async def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2147,8 +1993,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -2171,26 +2019,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2204,8 +2042,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -2223,8 +2064,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2232,38 +2075,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2281,6 +2119,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2296,26 +2135,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2328,6 +2157,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -2347,15 +2178,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2368,20 +2201,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2393,8 +2220,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -2414,26 +2243,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2443,10 +2262,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2458,31 +2278,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2310,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2518,15 +2331,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2537,26 +2355,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2568,8 +2381,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2589,26 +2404,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2622,8 +2427,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2648,26 +2456,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2680,6 +2478,7 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_subscription_scope_initial( self, deployment_name: str, @@ -2691,31 +2490,21 @@ async def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2734,8 +2523,11 @@ async def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_subscription_scope( self, deployment_name: str, @@ -2751,15 +2543,20 @@ async def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2770,26 +2567,21 @@ async def begin_validate_at_subscription_scope( raw_result = await self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2801,6 +2593,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_subscription_scope_initial( @@ -2814,31 +2607,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2846,21 +2629,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2876,15 +2663,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2895,26 +2687,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2926,8 +2713,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2947,26 +2736,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2980,8 +2759,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2996,8 +2778,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3005,38 +2789,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3054,6 +2833,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3070,27 +2850,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3103,6 +2873,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -3127,15 +2899,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3149,21 +2923,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3175,8 +2942,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -3200,27 +2969,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3230,10 +2989,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -3246,32 +3006,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3289,8 +3039,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -3311,15 +3064,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3331,27 +3089,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3363,8 +3115,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -3387,27 +3141,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3421,8 +3165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -3450,27 +3197,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3483,6 +3220,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_initial( self, resource_group_name: str, @@ -3495,32 +3233,22 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3539,8 +3267,11 @@ async def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -3560,15 +3291,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3580,27 +3316,21 @@ async def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3612,6 +3342,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_initial( @@ -3626,32 +3357,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3659,21 +3380,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3693,15 +3418,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3713,27 +3443,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3745,8 +3469,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3769,27 +3495,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3803,8 +3519,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3823,8 +3542,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3832,39 +3553,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3882,11 +3599,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3906,26 +3625,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3939,4 +3651,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py index 42fa6e526643d..73a7b9a9f81a5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2019_10_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_providers_operations.py index 05ab8a1e8f789..ccac37d53d937 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -114,26 +113,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -147,8 +136,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -165,7 +157,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -173,38 +166,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -222,11 +210,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -243,7 +233,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -251,34 +242,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -296,11 +284,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -324,28 +314,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -359,8 +338,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -384,27 +366,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -418,4 +389,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resource_groups_operations.py index 7a86de6afe6ed..d76766fdb0e9d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -174,26 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -221,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -242,20 +226,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -267,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -351,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -389,8 +352,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -402,31 +367,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,8 +397,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -458,15 +416,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -477,26 +440,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -508,8 +466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -525,8 +485,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -534,38 +496,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -583,6 +540,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resources_operations.py index 1434e5ac18bc1..9d31526364a4d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,11 +394,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -419,40 +407,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,11 +453,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -510,29 +495,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -542,10 +519,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -561,29 +539,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +566,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -623,15 +595,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -649,24 +623,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -678,6 +642,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -696,34 +661,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +699,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -774,15 +734,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,30 +763,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -833,6 +789,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -851,34 +808,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -894,8 +843,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -926,15 +878,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -950,30 +907,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -985,8 +933,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1022,29 +972,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1058,8 +1000,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1084,24 +1029,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1111,10 +1048,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1126,24 +1064,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1156,6 +1086,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1172,15 +1104,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1194,19 +1128,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1218,6 +1147,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1232,29 +1162,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1273,8 +1195,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1294,15 +1219,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1314,25 +1244,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1344,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1358,29 +1285,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1396,8 +1315,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1417,15 +1339,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1437,25 +1364,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1467,8 +1390,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1493,24 +1418,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1524,4 +1441,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_tags_operations.py index 370bb9dd64988..150c9191c6b3c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_at_scope_request, build_create_or_update_request, build_create_or_update_value_request, build_delete_at_scope_request, build_delete_request, build_delete_value_request, build_get_at_scope_request, build_list_request, build_update_at_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -67,27 +73,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,6 +96,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -125,27 +123,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +151,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -189,26 +180,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +207,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -251,26 +235,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +257,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -296,7 +272,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -304,34 +281,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +321,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace_async async def create_or_update_at_scope( self, scope: str, @@ -379,30 +353,20 @@ async def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,8 +380,11 @@ async def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def update_at_scope( self, scope: str, @@ -447,30 +414,20 @@ async def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,8 +441,11 @@ async def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -507,25 +467,15 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,8 +489,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def delete_at_scope( self, scope: str, @@ -562,25 +515,15 @@ async def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -592,3 +535,4 @@ async def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models.py index 10c9c15c13e81..e8eed329abfd1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models.py @@ -12,17 +12,17 @@ class Alias(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { @@ -37,6 +37,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -48,12 +61,12 @@ def __init__( class AliasPath(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { @@ -66,6 +79,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -75,12 +96,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType """ _attribute_map = { @@ -93,6 +114,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -102,12 +131,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -120,6 +149,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -129,13 +166,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -146,6 +183,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -153,14 +199,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -174,6 +220,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -186,12 +242,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -208,6 +264,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -217,8 +281,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -229,6 +293,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -244,13 +312,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -272,6 +340,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -284,8 +361,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -296,6 +373,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -305,8 +386,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -324,6 +405,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -338,8 +423,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationProperties """ @@ -358,6 +443,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -424,6 +514,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -442,8 +534,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -461,6 +553,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -471,34 +567,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment """ _validation = { @@ -519,6 +616,37 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -618,6 +746,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -645,8 +775,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended """ @@ -663,6 +793,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) @@ -673,10 +808,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -692,6 +828,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -702,36 +845,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings """ @@ -754,6 +898,40 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -761,9 +939,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ @@ -775,6 +953,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -804,6 +988,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -847,6 +1033,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -858,13 +1046,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -876,6 +1064,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -892,10 +1089,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -916,6 +1113,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -935,22 +1138,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity """ _validation = { @@ -978,6 +1181,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -998,22 +1219,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1056,6 +1277,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1065,12 +1304,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1083,6 +1322,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1092,8 +1339,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1104,6 +1351,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1117,13 +1368,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1143,6 +1394,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.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.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1175,6 +1436,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1183,11 +1446,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1199,6 +1462,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1211,11 +1481,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1232,6 +1502,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1241,10 +1518,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay """ _attribute_map = { @@ -1256,6 +1533,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1264,14 +1547,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1285,6 +1568,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1295,10 +1588,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1310,6 +1603,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1320,10 +1619,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1339,6 +1638,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1347,16 +1652,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1371,6 +1676,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1386,8 +1703,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1416,6 +1733,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1429,8 +1750,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1448,6 +1769,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1456,20 +1781,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1486,6 +1811,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1509,15 +1850,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1541,6 +1882,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1554,10 +1907,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _attribute_map = { @@ -1569,6 +1922,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1577,10 +1936,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1592,6 +1951,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1602,8 +1967,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1621,6 +1986,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1629,14 +1998,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1650,6 +2019,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1678,6 +2058,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1687,8 +2069,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1706,6 +2088,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1714,16 +2101,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1738,6 +2125,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1767,6 +2166,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -1774,10 +2175,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1789,6 +2190,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1799,12 +2206,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1822,6 +2229,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -1833,10 +2248,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -1853,6 +2269,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -1861,18 +2284,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -1888,6 +2311,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1900,8 +2337,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -1912,6 +2349,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -1919,10 +2360,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -1934,6 +2375,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -1946,13 +2393,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] """ _validation = { @@ -1970,6 +2417,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1980,8 +2436,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1992,6 +2448,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -2001,8 +2461,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2020,6 +2480,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2028,11 +2492,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _attribute_map = { @@ -2044,6 +2508,14 @@ def __init__( self, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) @@ -2062,8 +2534,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _validation = { @@ -2084,6 +2556,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2098,10 +2574,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount """ _validation = { @@ -2118,6 +2594,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -2127,12 +2609,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2145,6 +2627,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -2154,10 +2644,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2169,6 +2659,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -2179,10 +2675,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2198,6 +2694,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -2208,18 +2710,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2239,6 +2741,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2250,12 +2766,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] """ _attribute_map = { @@ -2268,6 +2784,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2279,18 +2803,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2310,6 +2834,21 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] @@ -2321,10 +2860,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2336,6 +2875,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py index c065ef352f215..d6668d2ee27da 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_models_py3.py @@ -16,17 +16,17 @@ class Alias(msrest.serialization.Model): """The alias type. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { @@ -47,6 +47,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2019_10_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -58,12 +71,12 @@ def __init__( class AliasPath(msrest.serialization.Model): """The type of the paths for alias. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { @@ -80,6 +93,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -89,12 +110,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType """ _attribute_map = { @@ -111,6 +132,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -120,12 +149,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -142,6 +171,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -151,13 +188,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -170,6 +207,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -177,14 +223,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -203,6 +249,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2019_10_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -215,12 +271,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -241,6 +297,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -250,8 +314,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -264,6 +328,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -279,13 +347,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -311,6 +379,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -323,8 +400,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -337,6 +414,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -346,8 +427,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -367,6 +448,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -381,8 +466,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationProperties """ @@ -403,6 +488,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -469,6 +559,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -487,8 +579,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -508,6 +600,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -518,34 +614,35 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment """ _validation = { @@ -574,6 +671,37 @@ def __init__( on_error_deployment: Optional["OnErrorDeployment"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -673,6 +801,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -700,8 +830,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended """ @@ -720,6 +850,11 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties @@ -730,10 +865,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -752,6 +888,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -762,36 +905,37 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :vartype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings """ @@ -823,6 +967,40 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2019_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, **kwargs) self.what_if_settings = what_if_settings @@ -830,9 +1008,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ @@ -846,6 +1024,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -875,6 +1059,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -918,6 +1104,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -929,13 +1117,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -950,6 +1138,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -966,10 +1163,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -993,6 +1190,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1012,22 +1215,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity """ _validation = { @@ -1064,6 +1267,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1084,22 +1305,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1151,6 +1372,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2019_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2019_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2019_10_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1160,12 +1399,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1182,6 +1421,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1191,8 +1438,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1205,6 +1452,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1218,13 +1469,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1247,6 +1498,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.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.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1279,6 +1540,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1287,11 +1550,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1306,6 +1569,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1318,11 +1588,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1342,6 +1612,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1351,10 +1628,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay """ _attribute_map = { @@ -1369,6 +1646,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1377,14 +1660,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1403,6 +1686,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1413,10 +1706,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1431,6 +1724,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1441,10 +1740,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1463,6 +1762,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1471,16 +1776,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1501,6 +1806,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1516,8 +1833,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1548,6 +1865,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1561,8 +1882,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1582,6 +1903,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1590,20 +1915,20 @@ def __init__( class ProviderResourceType(msrest.serialization.Model): """Resource type managed by the resource provider. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1628,6 +1953,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2019_10_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1651,15 +1992,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1688,6 +2029,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1701,10 +2054,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _attribute_map = { @@ -1719,6 +2072,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1727,10 +2086,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1745,6 +2104,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1755,8 +2120,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1776,6 +2141,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1784,14 +2153,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1810,6 +2179,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1838,6 +2218,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1847,8 +2229,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1868,6 +2250,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1876,16 +2263,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1906,6 +2293,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1935,6 +2334,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -1942,10 +2343,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1960,6 +2361,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -1970,12 +2377,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1997,6 +2404,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2008,10 +2423,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2031,6 +2447,13 @@ def __init__( properties: "DeploymentWhatIfProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2039,18 +2462,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2073,6 +2496,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2085,8 +2522,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2099,6 +2536,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -2106,10 +2547,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2124,6 +2565,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -2136,13 +2583,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] """ _validation = { @@ -2164,6 +2611,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2174,8 +2630,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2188,6 +2644,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags @@ -2197,8 +2657,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2218,6 +2678,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2226,11 +2690,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _attribute_map = { @@ -2245,6 +2709,14 @@ def __init__( properties: Optional["Tags"] = None, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties @@ -2263,8 +2735,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ _validation = { @@ -2287,6 +2759,10 @@ def __init__( properties: "Tags", **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2301,10 +2777,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount """ _validation = { @@ -2324,6 +2800,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2019_10_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2333,12 +2815,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2355,6 +2837,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2364,10 +2854,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2382,6 +2872,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2392,10 +2888,10 @@ class TemplateLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the template to deploy. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the template to deploy. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -2414,6 +2910,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the template to deploy. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -2424,18 +2926,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2461,6 +2963,20 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2472,12 +2988,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] """ _attribute_map = { @@ -2494,6 +3010,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2505,18 +3029,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2542,6 +3066,21 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type @@ -2553,10 +3092,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2571,6 +3110,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py index 6a354b9a831b3..ee5ba746c5827 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -35,7 +20,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -46,7 +31,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -69,7 +54,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -80,7 +65,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -88,7 +73,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -104,7 +89,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the current provisioning operation. """ @@ -130,7 +115,7 @@ class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -139,7 +124,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation type for the patch API. """ @@ -151,7 +136,7 @@ class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py index 19e8eb90234c2..bbb5389f9c9ff 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployments_operations.py index 1f93630db97e0..f4d854fa5686b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployments_operations.py @@ -5,26 +5,1637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1670,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1692,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1717,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1741,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -161,8 +1760,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1787,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1806,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1824,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1856,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1881,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1906,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -347,8 +1932,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1959,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1982,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +2015,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +2037,7 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_scope_initial( self, scope, # type: str @@ -480,31 +2051,21 @@ def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,8 +2084,11 @@ def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_scope( self, scope, # type: str @@ -544,15 +2108,20 @@ def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -564,26 +2133,21 @@ def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -595,8 +2159,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -620,26 +2186,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +2209,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -673,8 +2232,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -682,38 +2243,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -731,6 +2287,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -747,25 +2304,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -778,6 +2325,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -798,15 +2347,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -819,19 +2370,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -843,8 +2389,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -865,25 +2413,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -893,10 +2431,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -909,30 +2448,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,8 +2479,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -969,15 +2501,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -988,25 +2525,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1018,8 +2551,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2575,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1072,8 +2597,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1099,25 +2627,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,6 +2648,7 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_tenant_scope_initial( self, deployment_name, # type: str @@ -1142,30 +2661,20 @@ def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1184,8 +2693,11 @@ def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_tenant_scope( self, deployment_name, # type: str @@ -1202,15 +2714,20 @@ def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1221,25 +2738,21 @@ def begin_validate_at_tenant_scope( raw_result = self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1251,6 +2764,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_tenant_scope_initial( @@ -1265,30 +2779,20 @@ def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1296,21 +2800,25 @@ def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_tenant_scope( self, deployment_name, # type: str @@ -1327,15 +2835,20 @@ def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1346,25 +2859,21 @@ def begin_what_if_at_tenant_scope( raw_result = self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1376,8 +2885,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1398,25 +2909,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +2931,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1447,8 +2951,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1456,34 +2962,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1501,6 +3004,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1518,26 +3022,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,6 +3044,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1573,15 +3069,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1595,20 +3093,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1620,8 +3112,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1645,26 +3139,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1674,10 +3158,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1691,31 +3176,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1733,8 +3208,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1755,15 +3233,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1775,26 +3258,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1806,8 +3284,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1831,26 +3311,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1864,8 +3334,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1894,26 +3367,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1926,6 +3389,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_management_group_scope_initial( self, group_id, # type: str @@ -1939,31 +3403,21 @@ def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1982,8 +3436,11 @@ def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_management_group_scope( self, group_id, # type: str @@ -2003,15 +3460,20 @@ def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2023,26 +3485,21 @@ def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2054,6 +3511,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_management_group_scope_initial( @@ -2069,31 +3527,21 @@ def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2101,21 +3549,25 @@ def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_management_group_scope( self, group_id, # type: str @@ -2135,15 +3587,20 @@ def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2155,26 +3612,21 @@ def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2186,8 +3638,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -2211,26 +3665,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2244,8 +3688,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -2264,8 +3711,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2273,38 +3722,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2322,6 +3766,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2338,26 +3783,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2370,6 +3805,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -2390,15 +3827,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2411,20 +3850,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2436,8 +3869,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2458,26 +3893,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2487,10 +3912,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2503,31 +3929,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3961,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2564,15 +3983,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2583,26 +4007,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2614,8 +4033,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2636,26 +4057,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2669,8 +4080,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2696,26 +4110,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2728,6 +4132,7 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2740,31 +4145,21 @@ def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2783,8 +4178,11 @@ def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_subscription_scope( self, deployment_name, # type: str @@ -2801,15 +4199,20 @@ def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2820,26 +4223,21 @@ def begin_validate_at_subscription_scope( raw_result = self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2851,6 +4249,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_subscription_scope_initial( @@ -2865,31 +4264,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2897,21 +4286,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2928,15 +4321,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2947,26 +4345,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2978,8 +4371,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -3000,26 +4395,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3033,8 +4418,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -3050,8 +4438,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3059,38 +4449,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3108,6 +4493,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3125,27 +4511,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3158,6 +4534,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -3183,15 +4561,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3205,21 +4585,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3231,8 +4604,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -3257,27 +4632,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3287,10 +4652,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -3304,32 +4670,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3347,8 +4703,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -3370,15 +4729,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3390,27 +4754,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3422,8 +4780,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -3447,27 +4807,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3481,8 +4831,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3511,27 +4864,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3544,6 +4887,7 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_initial( self, resource_group_name, # type: str @@ -3557,32 +4901,22 @@ def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3601,8 +4935,11 @@ def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate( self, resource_group_name, # type: str @@ -3623,15 +4960,20 @@ def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3643,27 +4985,21 @@ def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3675,6 +5011,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( @@ -3690,32 +5027,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3723,21 +5050,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3758,15 +5089,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3778,27 +5114,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3810,8 +5140,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3835,27 +5167,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3869,8 +5191,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3890,8 +5215,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3899,39 +5226,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3949,11 +5272,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3974,26 +5299,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -4007,4 +5325,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py index 546439566d4e7..486be0ee214e3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2019_10_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_providers_operations.py index 4e962822e8c25..34a967341201f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_providers_operations.py @@ -5,24 +5,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +267,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +288,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +311,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -120,26 +336,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -153,8 +359,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -172,7 +381,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -180,38 +390,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -229,11 +434,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -251,7 +458,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -259,34 +467,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,11 +509,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -333,28 +540,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -368,8 +564,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -394,27 +593,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -428,4 +616,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resource_groups_operations.py index 1765feca2f74e..80a9c46e15bce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resource_groups_operations.py @@ -5,26 +5,289 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +310,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +332,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +351,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +382,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +414,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -181,26 +429,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,6 +451,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -229,15 +469,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -250,20 +492,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -275,8 +511,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -298,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -361,31 +592,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,8 +620,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -413,31 +636,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -453,8 +666,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -470,15 +686,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -489,26 +710,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -520,8 +736,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -538,8 +756,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -547,38 +767,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -596,6 +811,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resources_operations.py index a6881b0379121..a2bca362f1a32 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,11 +961,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +974,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +1020,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -521,29 +1063,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -553,10 +1087,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -573,29 +1108,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,6 +1135,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -636,15 +1165,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -662,24 +1193,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -691,6 +1212,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -710,34 +1232,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -756,8 +1270,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -789,15 +1306,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -813,30 +1335,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -848,6 +1361,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -867,34 +1381,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -910,8 +1416,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -943,15 +1452,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -967,30 +1481,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1002,8 +1507,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1040,29 +1547,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1076,8 +1575,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1103,24 +1605,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,10 +1624,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1146,24 +1641,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1176,6 +1663,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1193,15 +1682,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1215,19 +1706,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1239,6 +1725,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1254,29 +1741,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1295,8 +1774,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1317,15 +1799,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1337,25 +1824,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1367,6 +1850,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1382,29 +1866,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1420,8 +1896,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1442,15 +1921,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1462,25 +1946,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1492,8 +1972,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1519,24 +2001,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,4 +2024,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_tags_operations.py index 39055169a46e3..e7462b4efc7df 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_tags_operations.py @@ -5,24 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + + +def build_create_or_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +361,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -72,27 +389,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +412,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -131,27 +440,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +468,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -196,26 +498,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -259,26 +554,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +576,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -305,7 +592,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -313,34 +601,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,11 +641,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace def create_or_update_at_scope( self, scope, # type: str @@ -389,30 +674,20 @@ def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,8 +701,11 @@ def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def update_at_scope( self, scope, # type: str @@ -458,30 +736,20 @@ def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,8 +763,11 @@ def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def get_at_scope( self, scope, # type: str @@ -519,25 +790,15 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,8 +812,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def delete_at_scope( self, scope, # type: str @@ -575,25 +839,15 @@ def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,3 +859,4 @@ def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py index 9f710010e8105..9cfe880148bc5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json index c5e6b0262dba9..8604124ebda51 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py index f62d7da4e575d..13d2fc0f18f9a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_resource_management_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -35,75 +29,80 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2020_06_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2020_06_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2020_06_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2020_06_01.operations.ProvidersOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2020_06_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2020_06_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2020_06_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2020_06_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2020_06_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2020_06_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py index 23951f60adad1..c2d21e521667a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py index e2b2899b8bf0f..79cd880c33708 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/_resource_management_client.py @@ -6,100 +6,101 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2020_06_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2020_06_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2020_06_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2020_06_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2020_06_01.aio.operations.ProvidersOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2020_06_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2020_06_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2020_06_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2020_06_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2020_06_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2020_06_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2020_06_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployment_operations_operations.py index 5d7ba97f87e15..50c07495fc5fb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployments_operations.py index 3aa5d0b97edbb..7d48ea23dc6cf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request_initial, build_validate_at_scope_request_initial, build_validate_at_subscription_scope_request_initial, build_validate_at_tenant_scope_request_initial, build_validate_request_initial, build_what_if_at_management_group_scope_request_initial, build_what_if_at_subscription_scope_request_initial, build_what_if_at_tenant_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,7 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_scope_initial( self, scope: str, @@ -468,31 +433,21 @@ async def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -511,8 +466,11 @@ async def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_scope( self, scope: str, @@ -531,15 +489,20 @@ async def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -551,26 +514,21 @@ async def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -582,8 +540,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -606,26 +566,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -639,8 +589,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -658,8 +611,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -667,38 +622,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -716,6 +666,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -731,25 +682,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,6 +703,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -781,15 +724,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -802,19 +747,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -826,8 +766,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -847,25 +789,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,10 +807,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -890,30 +823,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,8 +854,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -949,15 +875,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -968,25 +899,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -998,8 +925,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +948,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1051,8 +970,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1077,25 +999,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1108,6 +1020,7 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_tenant_scope_initial( self, deployment_name: str, @@ -1119,30 +1032,20 @@ async def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1161,8 +1064,11 @@ async def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_tenant_scope( self, deployment_name: str, @@ -1178,15 +1084,20 @@ async def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1197,25 +1108,21 @@ async def begin_validate_at_tenant_scope( raw_result = await self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1227,6 +1134,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_tenant_scope_initial( @@ -1240,30 +1148,20 @@ async def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,21 +1169,25 @@ async def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_tenant_scope( self, deployment_name: str, @@ -1301,15 +1203,20 @@ async def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1320,25 +1227,21 @@ async def begin_what_if_at_tenant_scope( raw_result = await self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1350,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1371,25 +1276,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1403,8 +1298,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1419,8 +1317,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1428,34 +1328,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1473,6 +1370,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1489,26 +1387,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1521,6 +1409,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1543,15 +1433,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1565,20 +1457,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1590,8 +1476,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1614,26 +1502,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1643,10 +1521,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1659,31 +1538,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1701,8 +1570,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1722,15 +1594,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1742,26 +1619,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1773,8 +1645,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1797,26 +1671,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1830,8 +1694,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1859,26 +1726,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1891,6 +1748,7 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_management_group_scope_initial( self, group_id: str, @@ -1903,31 +1761,21 @@ async def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1946,8 +1794,11 @@ async def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_management_group_scope( self, group_id: str, @@ -1966,15 +1817,20 @@ async def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1986,26 +1842,21 @@ async def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -2017,6 +1868,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_management_group_scope_initial( @@ -2031,31 +1883,21 @@ async def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2063,21 +1905,25 @@ async def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_management_group_scope( self, group_id: str, @@ -2096,15 +1942,20 @@ async def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2116,26 +1967,21 @@ async def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2147,8 +1993,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -2171,26 +2019,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2204,8 +2042,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -2223,8 +2064,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2232,38 +2075,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2281,6 +2119,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2296,26 +2135,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2328,6 +2157,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -2347,15 +2178,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2368,20 +2201,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2393,8 +2220,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -2414,26 +2243,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2443,10 +2262,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2458,31 +2278,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2310,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2518,15 +2331,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2537,26 +2355,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2568,8 +2381,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2589,26 +2404,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2622,8 +2427,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2648,26 +2456,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2680,6 +2478,7 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_subscription_scope_initial( self, deployment_name: str, @@ -2691,31 +2490,21 @@ async def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2734,8 +2523,11 @@ async def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_subscription_scope( self, deployment_name: str, @@ -2751,15 +2543,20 @@ async def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2770,26 +2567,21 @@ async def begin_validate_at_subscription_scope( raw_result = await self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2801,6 +2593,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_subscription_scope_initial( @@ -2814,31 +2607,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2846,21 +2629,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2876,15 +2663,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2895,26 +2687,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2926,8 +2713,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2947,26 +2736,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2980,8 +2759,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2996,8 +2778,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3005,38 +2789,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3054,6 +2833,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3070,27 +2850,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3103,6 +2873,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -3127,15 +2899,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3149,21 +2923,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3175,8 +2942,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -3200,27 +2969,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3230,10 +2989,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -3246,32 +3006,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3289,8 +3039,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -3311,15 +3064,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3331,27 +3089,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3363,8 +3115,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -3387,27 +3141,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3421,8 +3165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -3450,27 +3197,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3483,6 +3220,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_initial( self, resource_group_name: str, @@ -3495,32 +3233,22 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3539,8 +3267,11 @@ async def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -3560,15 +3291,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3580,27 +3316,21 @@ async def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3612,6 +3342,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_initial( @@ -3626,32 +3357,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3659,21 +3380,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3693,15 +3418,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3713,27 +3443,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3745,8 +3469,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3769,27 +3495,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3803,8 +3519,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3823,8 +3542,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3832,39 +3553,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3882,11 +3599,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3906,26 +3625,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3939,4 +3651,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py index 29b3fe4f2156d..3742e0405627f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2020_06_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_providers_operations.py index 95a24e3dcb741..a8bbcfef5c6ca 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_at_management_group_scope_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register_at_management_group_scope( self, resource_provider_namespace: str, @@ -117,26 +116,16 @@ async def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -149,6 +138,8 @@ async def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -168,26 +159,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,8 +182,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -219,7 +203,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -227,38 +212,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -276,11 +256,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -297,7 +279,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -305,34 +288,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,11 +330,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -378,28 +360,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,8 +384,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -438,27 +412,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,4 +435,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resource_groups_operations.py index 5ee18fa1b33f9..6740722f1caa2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -175,28 +165,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +188,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -229,15 +210,17 @@ async def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -251,20 +234,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -276,8 +253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -298,26 +277,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +300,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -360,31 +332,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -398,8 +360,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -411,31 +375,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -451,8 +405,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -467,15 +424,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -486,26 +448,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -517,8 +474,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -534,8 +493,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -543,38 +504,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -592,6 +548,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resources_operations.py index 7d03dedda240a..1c4f27c815cfa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,11 +394,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -419,40 +407,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,11 +453,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -510,29 +495,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -542,10 +519,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -561,29 +539,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +566,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -623,15 +595,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -649,24 +623,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -678,6 +642,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -696,34 +661,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +699,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -774,15 +734,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,30 +763,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -833,6 +789,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -851,34 +808,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -894,8 +843,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -926,15 +878,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -950,30 +907,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -985,8 +933,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1022,29 +972,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1058,8 +1000,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1084,24 +1029,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1111,10 +1048,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1126,24 +1064,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1156,6 +1086,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1172,15 +1104,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1194,19 +1128,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1218,6 +1147,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1232,29 +1162,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1273,8 +1195,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1294,15 +1219,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1314,25 +1244,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1344,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1358,29 +1285,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1396,8 +1315,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1417,15 +1339,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1437,25 +1364,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1467,8 +1390,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1493,24 +1418,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1524,4 +1441,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_tags_operations.py index d905bb2f83e84..e2610e0485841 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_at_scope_request, build_create_or_update_request, build_create_or_update_value_request, build_delete_at_scope_request, build_delete_request, build_delete_value_request, build_get_at_scope_request, build_list_request, build_update_at_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -67,27 +73,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,6 +96,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -125,27 +123,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +151,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -189,26 +180,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +207,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -251,26 +235,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +257,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -296,7 +272,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -304,34 +281,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +321,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace_async async def create_or_update_at_scope( self, scope: str, @@ -379,30 +353,20 @@ async def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,8 +380,11 @@ async def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def update_at_scope( self, scope: str, @@ -447,30 +414,20 @@ async def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,8 +441,11 @@ async def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -507,25 +467,15 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,8 +489,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def delete_at_scope( self, scope: str, @@ -562,25 +515,15 @@ async def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -592,3 +535,4 @@ async def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models.py index fcca90ab86b85..6c7d50ee58591 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -130,12 +153,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType """ _attribute_map = { @@ -148,6 +171,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -179,6 +210,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -187,12 +220,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -205,6 +238,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -214,13 +255,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -231,6 +272,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -238,14 +288,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -259,6 +309,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -271,12 +331,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -293,6 +353,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -302,8 +370,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -314,6 +382,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -329,13 +401,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -357,6 +429,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -369,8 +450,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -381,6 +462,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -390,8 +475,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -409,6 +494,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -423,8 +512,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationProperties """ @@ -443,6 +532,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -511,6 +605,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -529,8 +625,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -548,6 +644,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -558,38 +658,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions """ @@ -612,6 +713,42 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -715,6 +852,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -742,8 +881,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended """ @@ -760,6 +899,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) @@ -770,10 +914,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { @@ -789,6 +934,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -799,41 +951,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfSettings """ @@ -857,6 +1010,45 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -864,9 +1056,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat """ @@ -878,6 +1070,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -907,6 +1105,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -950,6 +1150,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -961,13 +1163,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -979,6 +1181,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -987,9 +1198,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1001,6 +1212,12 @@ def __init__( self, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = kwargs.get('scope', None) @@ -1016,10 +1233,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1040,6 +1257,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1059,22 +1282,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity """ _validation = { @@ -1101,6 +1324,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -1121,22 +1362,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1178,6 +1419,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1187,12 +1446,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1205,6 +1464,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1214,8 +1481,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1226,6 +1493,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1239,13 +1510,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_06_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1265,6 +1536,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.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.resource.resources.v2020_06_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1297,6 +1578,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1305,11 +1588,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1321,6 +1604,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1333,11 +1623,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1354,6 +1644,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1363,10 +1660,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay """ _attribute_map = { @@ -1378,6 +1675,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1386,14 +1689,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1407,6 +1710,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1417,10 +1730,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1432,6 +1745,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1442,10 +1761,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1461,6 +1780,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1469,16 +1794,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1493,6 +1818,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1508,8 +1845,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1538,6 +1875,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1551,8 +1892,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1570,6 +1911,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1580,24 +1925,24 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2020_06_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1621,6 +1966,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1646,15 +2007,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1678,6 +2039,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1691,10 +2064,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ _attribute_map = { @@ -1706,6 +2079,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1714,10 +2093,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1729,6 +2108,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1739,8 +2124,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1758,6 +2143,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1766,14 +2155,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1787,6 +2176,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1815,6 +2215,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1824,8 +2226,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1843,6 +2245,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1851,16 +2258,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1875,6 +2282,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1904,6 +2323,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -1911,10 +2332,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1926,6 +2347,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1936,12 +2363,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1959,6 +2386,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -1970,10 +2405,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { @@ -1990,6 +2426,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -1998,18 +2441,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2025,6 +2468,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -2037,10 +2494,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ _attribute_map = { @@ -2052,6 +2509,12 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2060,8 +2523,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2072,6 +2535,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -2079,10 +2546,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2094,6 +2561,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -2106,13 +2579,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] """ _validation = { @@ -2130,6 +2603,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -2140,8 +2622,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2152,6 +2634,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -2161,8 +2647,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2180,6 +2666,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2188,11 +2678,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _attribute_map = { @@ -2204,6 +2694,14 @@ def __init__( self, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) @@ -2222,8 +2720,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _validation = { @@ -2244,6 +2742,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2258,10 +2760,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount """ _validation = { @@ -2278,6 +2780,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -2287,12 +2795,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2305,6 +2813,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -2314,10 +2830,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2329,6 +2845,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -2337,15 +2859,15 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: Applicable only if this template link references a Template Spec. This + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: Applicable only if this template link references a Template Spec. This relativePath property can optionally be used to reference a Template Spec artifact by path. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _attribute_map = { @@ -2359,6 +2881,19 @@ def __init__( self, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: Applicable only if this template link references a Template Spec. This + relativePath property can optionally be used to reference a Template Spec artifact by path. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs.get('uri', None) self.id = kwargs.get('id', None) @@ -2371,18 +2906,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { @@ -2402,6 +2937,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2413,12 +2962,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] """ _attribute_map = { @@ -2431,6 +2980,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2442,18 +2999,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { @@ -2473,6 +3030,21 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] @@ -2484,10 +3056,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2499,6 +3071,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py index 368bc76b18dab..2b4cad261fb41 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_models_py3.py @@ -18,17 +18,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathMetadata @@ -57,6 +57,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2020_06_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -71,12 +84,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPathMetadata @@ -101,6 +114,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -197,6 +228,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -205,12 +238,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -227,6 +260,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -236,13 +277,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -255,6 +296,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -262,14 +312,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -288,6 +338,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2020_06_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -300,12 +360,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -326,6 +386,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -335,8 +403,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -349,6 +417,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -364,13 +436,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -396,6 +468,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -408,8 +489,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -422,6 +503,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -431,8 +516,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -452,6 +537,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -466,8 +555,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationProperties """ @@ -488,6 +577,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -556,6 +650,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -574,8 +670,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -595,6 +691,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -605,38 +705,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions """ @@ -668,6 +769,42 @@ def __init__( expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -771,6 +908,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -798,8 +937,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended """ @@ -818,6 +957,11 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties @@ -828,10 +972,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { @@ -850,6 +995,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -860,41 +1012,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfSettings """ @@ -928,6 +1081,45 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_06_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_06_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_06_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) self.what_if_settings = what_if_settings @@ -935,9 +1127,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat """ @@ -951,6 +1143,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -980,6 +1178,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1023,6 +1223,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1034,13 +1236,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -1055,6 +1257,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -1063,9 +1274,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1079,6 +1290,12 @@ def __init__( scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = scope @@ -1094,10 +1311,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1121,6 +1338,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1140,22 +1363,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity """ _validation = { @@ -1191,6 +1414,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1211,22 +1452,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1277,6 +1518,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_06_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_06_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_06_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1286,12 +1545,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1308,6 +1567,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1317,8 +1584,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1331,6 +1598,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1344,13 +1615,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_06_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1373,6 +1644,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.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.resource.resources.v2020_06_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1405,6 +1686,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1413,11 +1696,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1432,6 +1715,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1444,11 +1734,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1468,6 +1758,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1477,10 +1774,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay """ _attribute_map = { @@ -1495,6 +1792,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2020_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1503,14 +1806,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1529,6 +1832,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1539,10 +1852,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1557,6 +1870,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1567,10 +1886,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1589,6 +1908,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1597,16 +1922,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1627,6 +1952,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1642,8 +1979,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1674,6 +2011,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1687,8 +2028,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1708,6 +2049,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1718,24 +2063,24 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2020_06_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1767,6 +2112,22 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2020_06_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2020_06_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1792,15 +2153,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1829,6 +2190,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1842,10 +2215,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ _attribute_map = { @@ -1860,6 +2233,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1868,10 +2247,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1886,6 +2265,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1896,8 +2281,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1917,6 +2302,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1925,14 +2314,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1951,6 +2340,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1979,6 +2379,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1988,8 +2390,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2009,6 +2411,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2017,16 +2424,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -2047,6 +2454,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -2076,6 +2495,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2083,10 +2504,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2101,6 +2522,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -2111,12 +2538,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2138,6 +2565,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2149,10 +2584,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2172,6 +2608,13 @@ def __init__( properties: "DeploymentWhatIfProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2180,18 +2623,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2214,6 +2657,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2226,10 +2683,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse """ _attribute_map = { @@ -2244,6 +2701,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = status self.error = error @@ -2252,8 +2715,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2266,6 +2729,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -2273,10 +2740,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2291,6 +2758,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -2303,13 +2776,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] """ _validation = { @@ -2331,6 +2804,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2341,8 +2823,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2355,6 +2837,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags @@ -2364,8 +2850,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2385,6 +2871,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_06_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2393,11 +2883,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _attribute_map = { @@ -2412,6 +2902,14 @@ def __init__( properties: Optional["Tags"] = None, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties @@ -2430,8 +2928,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags """ _validation = { @@ -2454,6 +2952,10 @@ def __init__( properties: "Tags", **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_06_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2468,10 +2970,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount """ _validation = { @@ -2491,6 +2993,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2020_06_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2500,12 +3008,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2522,6 +3030,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2531,10 +3047,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2549,6 +3065,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2557,15 +3079,15 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: Applicable only if this template link references a Template Spec. This + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: Applicable only if this template link references a Template Spec. This relativePath property can optionally be used to reference a Template Spec artifact by path. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _attribute_map = { @@ -2584,6 +3106,19 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: Applicable only if this template link references a Template Spec. This + relativePath property can optionally be used to reference a Template Spec artifact by path. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.id = id @@ -2596,18 +3131,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { @@ -2633,6 +3168,20 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2644,12 +3193,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] """ _attribute_map = { @@ -2666,6 +3215,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2020_06_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2677,18 +3234,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] """ _validation = { @@ -2714,6 +3271,21 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2020_06_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type @@ -2725,10 +3297,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2743,6 +3315,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py index cca321c6026ca..795ece2e655ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -99,7 +84,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -110,7 +95,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -119,7 +104,7 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMe OUTER = "Outer" INNER = "Inner" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -127,7 +112,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -143,7 +128,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the current provisioning operation. """ @@ -169,7 +154,7 @@ class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Denotes the state of provisioning. """ @@ -186,7 +171,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -195,7 +180,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation type for the patch API. """ @@ -207,7 +192,7 @@ class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployment_operations_operations.py index 9c6d523a87463..408b0ba42b19d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployments_operations.py index 926e6f3d766fd..909b33bb635b8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_deployments_operations.py @@ -5,26 +5,1637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_validate_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_validate_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1670,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1692,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1717,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1741,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -161,8 +1760,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1787,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1806,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1824,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1856,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1881,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1906,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -347,8 +1932,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1959,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1982,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +2015,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +2037,7 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_scope_initial( self, scope, # type: str @@ -480,31 +2051,21 @@ def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,8 +2084,11 @@ def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_scope( self, scope, # type: str @@ -544,15 +2108,20 @@ def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -564,26 +2133,21 @@ def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -595,8 +2159,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -620,26 +2186,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +2209,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -673,8 +2232,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -682,38 +2243,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -731,6 +2287,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -747,25 +2304,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -778,6 +2325,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -798,15 +2347,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -819,19 +2370,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -843,8 +2389,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -865,25 +2413,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -893,10 +2431,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -909,30 +2448,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,8 +2479,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -969,15 +2501,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -988,25 +2525,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1018,8 +2551,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2575,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1072,8 +2597,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1099,25 +2627,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,6 +2648,7 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_tenant_scope_initial( self, deployment_name, # type: str @@ -1142,30 +2661,20 @@ def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1184,8 +2693,11 @@ def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_tenant_scope( self, deployment_name, # type: str @@ -1202,15 +2714,20 @@ def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1221,25 +2738,21 @@ def begin_validate_at_tenant_scope( raw_result = self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1251,6 +2764,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_tenant_scope_initial( @@ -1265,30 +2779,20 @@ def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1296,21 +2800,25 @@ def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_tenant_scope( self, deployment_name, # type: str @@ -1327,15 +2835,20 @@ def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1346,25 +2859,21 @@ def begin_what_if_at_tenant_scope( raw_result = self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1376,8 +2885,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1398,25 +2909,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +2931,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1447,8 +2951,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1456,34 +2962,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1501,6 +3004,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1518,26 +3022,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,6 +3044,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1573,15 +3069,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1595,20 +3093,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1620,8 +3112,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1645,26 +3139,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1674,10 +3158,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1691,31 +3176,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1733,8 +3208,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1755,15 +3233,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1775,26 +3258,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1806,8 +3284,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1831,26 +3311,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1864,8 +3334,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1894,26 +3367,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1926,6 +3389,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_management_group_scope_initial( self, group_id, # type: str @@ -1939,31 +3403,21 @@ def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1982,8 +3436,11 @@ def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_management_group_scope( self, group_id, # type: str @@ -2003,15 +3460,20 @@ def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2023,26 +3485,21 @@ def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -2054,6 +3511,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_management_group_scope_initial( @@ -2069,31 +3527,21 @@ def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2101,21 +3549,25 @@ def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_management_group_scope( self, group_id, # type: str @@ -2135,15 +3587,20 @@ def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2155,26 +3612,21 @@ def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2186,8 +3638,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -2211,26 +3665,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2244,8 +3688,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -2264,8 +3711,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2273,38 +3722,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2322,6 +3766,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2338,26 +3783,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2370,6 +3805,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -2390,15 +3827,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2411,20 +3850,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2436,8 +3869,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2458,26 +3893,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2487,10 +3912,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2503,31 +3929,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3961,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2564,15 +3983,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2583,26 +4007,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2614,8 +4033,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2636,26 +4057,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2669,8 +4080,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2696,26 +4110,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2728,6 +4132,7 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2740,31 +4145,21 @@ def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2783,8 +4178,11 @@ def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_subscription_scope( self, deployment_name, # type: str @@ -2801,15 +4199,20 @@ def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2820,26 +4223,21 @@ def begin_validate_at_subscription_scope( raw_result = self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2851,6 +4249,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_subscription_scope_initial( @@ -2865,31 +4264,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2897,21 +4286,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2928,15 +4321,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2947,26 +4345,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2978,8 +4371,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -3000,26 +4395,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3033,8 +4418,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -3050,8 +4438,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3059,38 +4449,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3108,6 +4493,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3125,27 +4511,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3158,6 +4534,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -3183,15 +4561,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3205,21 +4585,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3231,8 +4604,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -3257,27 +4632,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3287,10 +4652,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -3304,32 +4670,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3347,8 +4703,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -3370,15 +4729,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3390,27 +4754,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3422,8 +4780,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -3447,27 +4807,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3481,8 +4831,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3511,27 +4864,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3544,6 +4887,7 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_initial( self, resource_group_name, # type: str @@ -3557,32 +4901,22 @@ def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3601,8 +4935,11 @@ def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate( self, resource_group_name, # type: str @@ -3623,15 +4960,20 @@ def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3643,27 +4985,21 @@ def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3675,6 +5011,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( @@ -3690,32 +5027,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3723,21 +5050,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3758,15 +5089,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3778,27 +5114,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3810,8 +5140,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3835,27 +5167,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3869,8 +5191,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3890,8 +5215,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3899,39 +5226,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3949,11 +5272,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3974,26 +5299,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -4007,4 +5325,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py index ef18f4630d228..7e7bb47a9dd5a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2020_06_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_providers_operations.py index 3bd1f6f084618..88da2cb14eb8e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_providers_operations.py @@ -5,24 +5,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_at_management_group_scope_request( + resource_provider_namespace, # type: str + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +301,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +322,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +345,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register_at_management_group_scope( self, resource_provider_namespace, # type: str @@ -123,26 +373,16 @@ def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -155,6 +395,8 @@ def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -175,26 +417,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,8 +440,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -227,7 +462,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -235,38 +471,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,11 +515,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -306,7 +539,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -314,34 +548,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,11 +590,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -388,28 +621,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -423,8 +645,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -449,27 +674,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -483,4 +697,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resource_groups_operations.py index 04df5be8f102a..4a09581be8978 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resource_groups_operations.py @@ -5,26 +5,293 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + force_deletion_types = kwargs.pop('force_deletion_types', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 force_deletion_types is not None: + query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, '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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +314,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +336,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +355,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +386,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +418,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -182,28 +434,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,6 +457,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -237,15 +480,17 @@ def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -259,20 +504,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -284,8 +523,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -307,26 +548,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,8 +571,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -370,31 +604,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -408,8 +632,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -422,31 +648,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -462,8 +678,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -479,15 +698,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -498,26 +722,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -529,8 +748,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -547,8 +768,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -556,38 +779,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,6 +823,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resources_operations.py index 001b7a05f21dc..09aa9084193cb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,11 +961,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +974,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +1020,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -521,29 +1063,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -553,10 +1087,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -573,29 +1108,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,6 +1135,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -636,15 +1165,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -662,24 +1193,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -691,6 +1212,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -710,34 +1232,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -756,8 +1270,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -789,15 +1306,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -813,30 +1335,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -848,6 +1361,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -867,34 +1381,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -910,8 +1416,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -943,15 +1452,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -967,30 +1481,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1002,8 +1507,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1040,29 +1547,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1076,8 +1575,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1103,24 +1605,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,10 +1624,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1146,24 +1641,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1176,6 +1663,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1193,15 +1682,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1215,19 +1706,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1239,6 +1725,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1254,29 +1741,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1295,8 +1774,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1317,15 +1799,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1337,25 +1824,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1367,6 +1850,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1382,29 +1866,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1420,8 +1896,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1442,15 +1921,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_06_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1462,25 +1946,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1492,8 +1972,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1519,24 +2001,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,4 +2024,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_tags_operations.py index 51db4878a8e30..798f02a626c04 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_06_01/operations/_tags_operations.py @@ -5,24 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + + +def build_create_or_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +361,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -72,27 +389,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +412,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -131,27 +440,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +468,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -196,26 +498,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -259,26 +554,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +576,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -305,7 +592,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_06_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -313,34 +601,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,11 +641,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace def create_or_update_at_scope( self, scope, # type: str @@ -389,30 +674,20 @@ def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,8 +701,11 @@ def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def update_at_scope( self, scope, # type: str @@ -458,30 +736,20 @@ def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,8 +763,11 @@ def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def get_at_scope( self, scope, # type: str @@ -519,25 +790,15 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,8 +812,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def delete_at_scope( self, scope, # type: str @@ -575,25 +839,15 @@ def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,3 +859,4 @@ def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py index 7874bef1927eb..174cabd95126c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json index 48a4ae75b98a4..f3f34fc2b8c67 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py index a9ba26b2d5555..248fd099f7f72 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_resource_management_client.py @@ -6,29 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -36,79 +29,84 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2020_10_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2020_10_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2020_10_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2020_10_01.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2020_10_01.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2020_10_01.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2020_10_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2020_10_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2020_10_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2020_10_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2020_10_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2020_10_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py index cda348c8b53e5..a8607ef09f6bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py index 0e947897b19ef..736531081ec4e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/_resource_management_client.py @@ -6,105 +6,105 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2020_10_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2020_10_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2020_10_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2020_10_01.aio.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2020_10_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2020_10_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2020_10_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2020_10_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2020_10_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployment_operations_operations.py index 0532aaf9b40ad..af12dfa5a6a46 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployments_operations.py index 406c817ac04d7..1cb96ee367ef2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request_initial, build_validate_at_scope_request_initial, build_validate_at_subscription_scope_request_initial, build_validate_at_tenant_scope_request_initial, build_validate_request_initial, build_what_if_at_management_group_scope_request_initial, build_what_if_at_subscription_scope_request_initial, build_what_if_at_tenant_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,7 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_scope_initial( self, scope: str, @@ -468,31 +433,21 @@ async def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -511,8 +466,11 @@ async def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_scope( self, scope: str, @@ -531,15 +489,20 @@ async def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -551,26 +514,21 @@ async def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -582,8 +540,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -606,26 +566,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -639,8 +589,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -658,8 +611,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -667,38 +622,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -716,6 +666,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -731,25 +682,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,6 +703,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -781,15 +724,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -802,19 +747,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -826,8 +766,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -847,25 +789,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,10 +807,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -890,30 +823,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,8 +854,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -949,15 +875,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -968,25 +899,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -998,8 +925,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +948,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1051,8 +970,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1077,25 +999,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1108,6 +1020,7 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_tenant_scope_initial( self, deployment_name: str, @@ -1119,30 +1032,20 @@ async def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1161,8 +1064,11 @@ async def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_tenant_scope( self, deployment_name: str, @@ -1178,15 +1084,20 @@ async def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1197,25 +1108,21 @@ async def begin_validate_at_tenant_scope( raw_result = await self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1227,6 +1134,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_tenant_scope_initial( @@ -1240,30 +1148,20 @@ async def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,21 +1169,25 @@ async def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_tenant_scope( self, deployment_name: str, @@ -1301,15 +1203,20 @@ async def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1320,25 +1227,21 @@ async def begin_what_if_at_tenant_scope( raw_result = await self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1350,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1371,25 +1276,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1403,8 +1298,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1419,8 +1317,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1428,34 +1328,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1473,6 +1370,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1489,26 +1387,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1521,6 +1409,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1543,15 +1433,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1565,20 +1457,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1590,8 +1476,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1614,26 +1502,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1643,10 +1521,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1659,31 +1538,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1701,8 +1570,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1722,15 +1594,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1742,26 +1619,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1773,8 +1645,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1797,26 +1671,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1830,8 +1694,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1859,26 +1726,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1891,6 +1748,7 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_management_group_scope_initial( self, group_id: str, @@ -1903,31 +1761,21 @@ async def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1946,8 +1794,11 @@ async def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_management_group_scope( self, group_id: str, @@ -1966,15 +1817,20 @@ async def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1986,26 +1842,21 @@ async def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -2017,6 +1868,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_management_group_scope_initial( @@ -2031,31 +1883,21 @@ async def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2063,21 +1905,25 @@ async def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_management_group_scope( self, group_id: str, @@ -2096,15 +1942,20 @@ async def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2116,26 +1967,21 @@ async def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2147,8 +1993,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -2171,26 +2019,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2204,8 +2042,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -2223,8 +2064,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2232,38 +2075,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2281,6 +2119,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2296,26 +2135,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2328,6 +2157,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -2347,15 +2178,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2368,20 +2201,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2393,8 +2220,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -2414,26 +2243,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2443,10 +2262,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2458,31 +2278,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2310,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2518,15 +2331,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2537,26 +2355,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2568,8 +2381,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2589,26 +2404,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2622,8 +2427,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2648,26 +2456,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2680,6 +2478,7 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_subscription_scope_initial( self, deployment_name: str, @@ -2691,31 +2490,21 @@ async def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2734,8 +2523,11 @@ async def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_subscription_scope( self, deployment_name: str, @@ -2751,15 +2543,20 @@ async def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2770,26 +2567,21 @@ async def begin_validate_at_subscription_scope( raw_result = await self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2801,6 +2593,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_subscription_scope_initial( @@ -2814,31 +2607,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2846,21 +2629,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2876,15 +2663,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2895,26 +2687,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2926,8 +2713,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2947,26 +2736,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2980,8 +2759,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2996,8 +2778,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3005,38 +2789,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3054,6 +2833,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3070,27 +2850,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3103,6 +2873,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -3127,15 +2899,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3149,21 +2923,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3175,8 +2942,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -3200,27 +2969,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3230,10 +2989,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -3246,32 +3006,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3289,8 +3039,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -3311,15 +3064,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3331,27 +3089,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3363,8 +3115,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -3387,27 +3141,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3421,8 +3165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -3450,27 +3197,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3483,6 +3220,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_initial( self, resource_group_name: str, @@ -3495,32 +3233,22 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3539,8 +3267,11 @@ async def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -3560,15 +3291,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3580,27 +3316,21 @@ async def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3612,6 +3342,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_initial( @@ -3626,32 +3357,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3659,21 +3380,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3693,15 +3418,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3713,27 +3443,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3745,8 +3469,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3769,27 +3495,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3803,8 +3519,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3823,8 +3542,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3832,39 +3553,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3882,11 +3599,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3906,26 +3625,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3939,4 +3651,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py index e277e786782b8..4ee34c2c86a86 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2020_10_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_provider_resource_types_operations.py index bcad068044f9f..3bc7c1aa552cd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_provider_resource_types_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._provider_resource_types_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_provider_namespace: str, @@ -63,28 +68,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,4 +92,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_providers_operations.py index ea6ef4749a583..c890a0a6502de 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_at_management_group_scope_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register_at_management_group_scope( self, resource_provider_namespace: str, @@ -117,26 +116,16 @@ async def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -149,6 +138,8 @@ async def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -168,26 +159,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,8 +182,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -219,7 +203,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -227,38 +212,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -276,11 +256,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -297,7 +279,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -305,34 +288,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,11 +330,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -378,28 +360,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,8 +384,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -438,27 +412,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,4 +435,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resource_groups_operations.py index 722f1e7c821e1..66cc4282fd412 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -174,26 +164,16 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -206,6 +186,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -221,15 +203,17 @@ async def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -242,20 +226,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -267,8 +245,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,26 +269,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -322,8 +292,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -351,31 +324,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -389,8 +352,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -402,31 +367,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -442,8 +397,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -458,15 +416,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -477,26 +440,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -508,8 +466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -525,8 +485,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -534,38 +496,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -583,6 +540,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resources_operations.py index 100db3c0d7586..be2f8778ee363 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,11 +394,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -419,40 +407,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,11 +453,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -510,29 +495,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -542,10 +519,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -561,29 +539,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +566,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -623,15 +595,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -649,24 +623,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -678,6 +642,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -696,34 +661,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +699,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -774,15 +734,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,30 +763,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -833,6 +789,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -851,34 +808,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -894,8 +843,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -926,15 +878,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -950,30 +907,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -985,8 +933,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1022,29 +972,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1058,8 +1000,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1084,24 +1029,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1111,10 +1048,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1126,24 +1064,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1156,6 +1086,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1172,15 +1104,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1194,19 +1128,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1218,6 +1147,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1232,29 +1162,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1273,8 +1195,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1294,15 +1219,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1314,25 +1244,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1344,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1358,29 +1285,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1396,8 +1315,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1417,15 +1339,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1437,25 +1364,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1467,8 +1390,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1493,24 +1418,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1524,4 +1441,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_tags_operations.py index 0e8eee6a0a367..701ba707fd8c8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_at_scope_request, build_create_or_update_request, build_create_or_update_value_request, build_delete_at_scope_request, build_delete_request, build_delete_value_request, build_get_at_scope_request, build_list_request, build_update_at_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -67,27 +73,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,6 +96,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -125,27 +123,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +151,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -189,26 +180,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +207,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -251,26 +235,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +257,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -296,7 +272,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -304,34 +281,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +321,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace_async async def create_or_update_at_scope( self, scope: str, @@ -379,30 +353,20 @@ async def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,8 +380,11 @@ async def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def update_at_scope( self, scope: str, @@ -447,30 +414,20 @@ async def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,8 +441,11 @@ async def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -507,25 +467,15 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,8 +489,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def delete_at_scope( self, scope: str, @@ -562,25 +515,15 @@ async def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -592,3 +535,4 @@ async def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models.py index 9fbb3c5c51e21..cf241f15c291a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -130,12 +153,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType """ _attribute_map = { @@ -148,6 +171,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -179,6 +210,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -187,12 +220,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -205,6 +238,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -214,13 +255,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -231,6 +272,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -238,14 +288,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -259,6 +309,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -271,12 +331,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -293,6 +353,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -302,8 +370,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -314,6 +382,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -329,13 +401,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -357,6 +429,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -369,8 +450,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -381,6 +462,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -390,8 +475,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -409,6 +494,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -423,8 +512,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationProperties """ @@ -443,6 +532,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -511,6 +605,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -529,8 +625,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -548,6 +644,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -558,38 +658,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions """ @@ -612,6 +713,42 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -715,6 +852,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -742,8 +881,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended """ @@ -760,6 +899,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) @@ -770,10 +914,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -789,6 +934,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -799,41 +951,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfSettings """ @@ -857,6 +1010,45 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -864,9 +1056,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat """ @@ -878,6 +1070,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -907,6 +1105,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -950,6 +1150,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -961,13 +1163,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -979,6 +1181,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -987,9 +1198,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1001,6 +1212,12 @@ def __init__( self, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = kwargs.get('scope', None) @@ -1016,10 +1233,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1040,6 +1257,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1059,22 +1282,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity """ _validation = { @@ -1101,6 +1324,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -1121,22 +1362,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1178,6 +1419,24 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1187,12 +1446,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1205,6 +1464,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1214,8 +1481,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1226,6 +1493,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1239,13 +1510,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_10_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1265,6 +1536,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.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.resource.resources.v2020_10_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1297,6 +1578,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1305,11 +1588,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1321,6 +1604,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1333,11 +1623,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1354,6 +1644,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1363,10 +1660,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay """ _attribute_map = { @@ -1378,6 +1675,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1386,14 +1689,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1407,6 +1710,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1417,10 +1730,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1432,6 +1745,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1442,10 +1761,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1461,6 +1780,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1469,16 +1794,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1493,6 +1818,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1508,8 +1845,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1538,6 +1875,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1549,12 +1890,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1567,6 +1908,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.type = kwargs.get('type', None) @@ -1578,8 +1927,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1597,6 +1946,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1607,27 +1960,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2020_10_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1652,6 +2005,25 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1670,8 +2042,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1689,6 +2061,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1707,15 +2083,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1739,6 +2115,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1752,10 +2140,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -1767,6 +2155,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1775,10 +2169,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1790,6 +2184,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1800,8 +2200,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1819,6 +2219,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1827,14 +2231,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1848,6 +2252,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1876,6 +2291,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1885,8 +2302,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1904,6 +2321,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1912,16 +2334,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1936,6 +2358,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1965,6 +2399,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -1972,10 +2408,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -1987,6 +2423,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -1997,12 +2439,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2020,6 +2462,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2031,10 +2481,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2051,6 +2502,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2059,18 +2517,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2086,6 +2544,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -2098,10 +2570,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -2113,6 +2585,12 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2121,8 +2599,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2133,6 +2611,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -2140,10 +2622,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2155,6 +2637,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -2167,13 +2655,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] """ _validation = { @@ -2191,6 +2679,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -2201,8 +2698,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2213,6 +2710,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -2222,8 +2723,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2241,6 +2742,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2249,11 +2754,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _attribute_map = { @@ -2265,6 +2770,14 @@ def __init__( self, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) @@ -2283,8 +2796,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _validation = { @@ -2305,6 +2818,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2319,10 +2836,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount """ _validation = { @@ -2339,6 +2856,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -2348,12 +2871,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2366,6 +2889,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -2375,10 +2906,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2390,6 +2921,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -2398,20 +2935,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2426,6 +2963,24 @@ def __init__( self, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs.get('uri', None) self.id = kwargs.get('id', None) @@ -2439,18 +2994,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2470,6 +3025,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2481,12 +3050,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] """ _attribute_map = { @@ -2499,6 +3068,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2510,18 +3087,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2541,6 +3118,21 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] @@ -2552,10 +3144,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2567,6 +3159,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py index 43546fd1edd21..d2607455f63da 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_models_py3.py @@ -18,17 +18,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathMetadata @@ -57,6 +57,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2020_10_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -71,12 +84,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPathMetadata @@ -101,6 +114,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -197,6 +228,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -205,12 +238,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -227,6 +260,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -236,13 +277,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -255,6 +296,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -262,14 +312,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -288,6 +338,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2020_10_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -300,12 +360,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -326,6 +386,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -335,8 +403,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -349,6 +417,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -364,13 +436,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -396,6 +468,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -408,8 +489,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -422,6 +503,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -431,8 +516,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -452,6 +537,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -466,8 +555,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationProperties """ @@ -488,6 +577,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -556,6 +650,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -574,8 +670,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -595,6 +691,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -605,38 +705,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions """ @@ -668,6 +769,42 @@ def __init__( expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -771,6 +908,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -798,8 +937,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended """ @@ -818,6 +957,11 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties @@ -828,10 +972,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -850,6 +995,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -860,41 +1012,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfSettings """ @@ -928,6 +1081,45 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2020_10_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2020_10_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2020_10_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) self.what_if_settings = what_if_settings @@ -935,9 +1127,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat """ @@ -951,6 +1143,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -980,6 +1178,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1023,6 +1223,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1034,13 +1236,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -1055,6 +1257,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -1063,9 +1274,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1079,6 +1290,12 @@ def __init__( scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = scope @@ -1094,10 +1311,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1121,6 +1338,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1140,22 +1363,22 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity """ _validation = { @@ -1191,6 +1414,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + """ super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1211,22 +1452,22 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1277,6 +1518,24 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2020_10_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2020_10_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2020_10_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1286,12 +1545,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1308,6 +1567,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1317,8 +1584,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1331,6 +1598,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1344,13 +1615,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2020_10_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1373,6 +1644,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.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.resource.resources.v2020_10_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1405,6 +1686,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1413,11 +1696,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1432,6 +1715,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1444,11 +1734,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1468,6 +1758,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1477,10 +1774,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay """ _attribute_map = { @@ -1495,6 +1792,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2020_10_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1503,14 +1806,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1529,6 +1832,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1539,10 +1852,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1557,6 +1870,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1567,10 +1886,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1589,6 +1908,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1597,16 +1922,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1627,6 +1952,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1642,8 +1979,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1674,6 +2011,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1685,12 +2026,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1707,6 +2048,14 @@ def __init__( extended_locations: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = location self.type = type @@ -1718,8 +2067,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1739,6 +2088,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1749,27 +2102,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str - :param zone_mappings: - :type zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2020_10_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1803,6 +2156,25 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2020_10_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2020_10_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1821,8 +2193,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1842,6 +2214,10 @@ def __init__( value: Optional[List["ProviderResourceType"]] = None, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1860,15 +2236,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1897,6 +2273,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1910,10 +2298,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -1928,6 +2316,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1936,10 +2330,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1954,6 +2348,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -1964,8 +2364,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1985,6 +2385,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1993,14 +2397,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2019,6 +2423,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -2047,6 +2462,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -2056,8 +2473,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2077,6 +2494,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2085,16 +2507,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -2115,6 +2537,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -2144,6 +2578,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2151,10 +2587,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2169,6 +2605,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -2179,12 +2621,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2206,6 +2648,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2217,10 +2667,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2240,6 +2691,13 @@ def __init__( properties: "DeploymentWhatIfProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2248,18 +2706,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2282,6 +2740,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2294,10 +2766,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse """ _attribute_map = { @@ -2312,6 +2784,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = status self.error = error @@ -2320,8 +2798,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2334,6 +2812,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -2341,10 +2823,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2359,6 +2841,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -2371,13 +2859,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] """ _validation = { @@ -2399,6 +2887,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2409,8 +2906,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2423,6 +2920,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags @@ -2432,8 +2933,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2453,6 +2954,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2020_10_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2461,11 +2966,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _attribute_map = { @@ -2480,6 +2985,14 @@ def __init__( properties: Optional["Tags"] = None, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties @@ -2498,8 +3011,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags """ _validation = { @@ -2522,6 +3035,10 @@ def __init__( properties: "Tags", **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2020_10_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2536,10 +3053,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount """ _validation = { @@ -2559,6 +3076,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2020_10_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2568,12 +3091,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2590,6 +3113,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2599,10 +3130,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2617,6 +3148,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2625,20 +3162,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2659,6 +3196,24 @@ def __init__( query_string: Optional[str] = None, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.id = id @@ -2672,18 +3227,18 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify". - :type change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2709,6 +3264,20 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.ChangeType + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2720,12 +3289,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] """ _attribute_map = { @@ -2742,6 +3311,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2020_10_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2753,18 +3330,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2790,6 +3367,21 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2020_10_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type @@ -2801,10 +3393,10 @@ def __init__( class ZoneMapping(msrest.serialization.Model): """ZoneMapping. - :param location: The location of the zone mapping. - :type location: str - :param zones: - :type zones: list[str] + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] """ _attribute_map = { @@ -2819,6 +3411,12 @@ def __init__( zones: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ super(ZoneMapping, self).__init__(**kwargs) self.location = location self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py index cca321c6026ca..795ece2e655ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -99,7 +84,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: deployment is executed. The properties of the resource will change. MODIFY = "Modify" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -110,7 +95,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -119,7 +104,7 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMe OUTER = "Outer" INNER = "Inner" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -127,7 +112,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -143,7 +128,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property is an array and contains nested changes. ARRAY = "Array" -class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the current provisioning operation. """ @@ -169,7 +154,7 @@ class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Denotes the state of provisioning. """ @@ -186,7 +171,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -195,7 +180,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation type for the patch API. """ @@ -207,7 +192,7 @@ class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployment_operations_operations.py index f5151ea931d32..798898b4d7e6c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployments_operations.py index 3fc79edca6500..0e4fa7ce6a7de 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_deployments_operations.py @@ -5,26 +5,1637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_validate_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_validate_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), + "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_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1670,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1692,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1717,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1741,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -161,8 +1760,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1787,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1806,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1824,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1856,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1881,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1906,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -347,8 +1932,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1959,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1982,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +2015,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +2037,7 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_scope_initial( self, scope, # type: str @@ -480,31 +2051,21 @@ def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,8 +2084,11 @@ def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_scope( self, scope, # type: str @@ -544,15 +2108,20 @@ def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -564,26 +2133,21 @@ def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -595,8 +2159,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -620,26 +2186,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +2209,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -673,8 +2232,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -682,38 +2243,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -731,6 +2287,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -747,25 +2304,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -778,6 +2325,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -798,15 +2347,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -819,19 +2370,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -843,8 +2389,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -865,25 +2413,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -893,10 +2431,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -909,30 +2448,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,8 +2479,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -969,15 +2501,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -988,25 +2525,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1018,8 +2551,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2575,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1072,8 +2597,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1099,25 +2627,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,6 +2648,7 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_tenant_scope_initial( self, deployment_name, # type: str @@ -1142,30 +2661,20 @@ def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1184,8 +2693,11 @@ def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_tenant_scope( self, deployment_name, # type: str @@ -1202,15 +2714,20 @@ def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1221,25 +2738,21 @@ def begin_validate_at_tenant_scope( raw_result = self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1251,6 +2764,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_tenant_scope_initial( @@ -1265,30 +2779,20 @@ def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1296,21 +2800,25 @@ def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_tenant_scope( self, deployment_name, # type: str @@ -1327,15 +2835,20 @@ def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1346,25 +2859,21 @@ def begin_what_if_at_tenant_scope( raw_result = self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1376,8 +2885,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1398,25 +2909,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +2931,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1447,8 +2951,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1456,34 +2962,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1501,6 +3004,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1518,26 +3022,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,6 +3044,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1573,15 +3069,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1595,20 +3093,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1620,8 +3112,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1645,26 +3139,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1674,10 +3158,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1691,31 +3176,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1733,8 +3208,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1755,15 +3233,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1775,26 +3258,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -1806,8 +3284,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1831,26 +3311,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1864,8 +3334,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1894,26 +3367,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1926,6 +3389,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_management_group_scope_initial( self, group_id, # type: str @@ -1939,31 +3403,21 @@ def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1982,8 +3436,11 @@ def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_management_group_scope( self, group_id, # type: str @@ -2003,15 +3460,20 @@ def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2023,26 +3485,21 @@ def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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: @@ -2054,6 +3511,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_management_group_scope_initial( @@ -2069,31 +3527,21 @@ def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2101,21 +3549,25 @@ def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_management_group_scope( self, group_id, # type: str @@ -2135,15 +3587,20 @@ def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2155,26 +3612,21 @@ def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2186,8 +3638,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -2211,26 +3665,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2244,8 +3688,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -2264,8 +3711,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2273,38 +3722,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2322,6 +3766,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2338,26 +3783,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2370,6 +3805,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -2390,15 +3827,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2411,20 +3850,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2436,8 +3869,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2458,26 +3893,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2487,10 +3912,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2503,31 +3929,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3961,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2564,15 +3983,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2583,26 +4007,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2614,8 +4033,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2636,26 +4057,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2669,8 +4080,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2696,26 +4110,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2728,6 +4132,7 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2740,31 +4145,21 @@ def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2783,8 +4178,11 @@ def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_subscription_scope( self, deployment_name, # type: str @@ -2801,15 +4199,20 @@ def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2820,26 +4223,21 @@ def begin_validate_at_subscription_scope( raw_result = self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -2851,6 +4249,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_subscription_scope_initial( @@ -2865,31 +4264,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2897,21 +4286,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2928,15 +4321,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2947,26 +4345,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2978,8 +4371,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -3000,26 +4395,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3033,8 +4418,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -3050,8 +4438,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3059,38 +4449,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3108,6 +4493,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3125,27 +4511,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3158,6 +4534,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -3183,15 +4561,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3205,21 +4585,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3231,8 +4604,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -3257,27 +4632,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3287,10 +4652,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -3304,32 +4670,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3347,8 +4703,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -3370,15 +4729,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3390,27 +4754,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3422,8 +4780,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -3447,27 +4807,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3481,8 +4831,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3511,27 +4864,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3544,6 +4887,7 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_initial( self, resource_group_name, # type: str @@ -3557,32 +4901,22 @@ def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3601,8 +4935,11 @@ def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate( self, resource_group_name, # type: str @@ -3623,15 +4960,20 @@ def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3643,27 +4985,21 @@ def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - '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: @@ -3675,6 +5011,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( @@ -3690,32 +5027,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3723,21 +5050,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3758,15 +5089,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3778,27 +5114,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3810,8 +5140,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3835,27 +5167,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3869,8 +5191,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3890,8 +5215,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3899,39 +5226,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3949,11 +5272,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3974,26 +5299,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -4007,4 +5325,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py index ac983f0b63dd2..f5ff209010c0d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2020_10_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_provider_resource_types_operations.py index 8155c82d70293..5ee31ab5a078b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_provider_resource_types_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProviderResourceTypesOperations(object): """ProviderResourceTypesOperations operations. @@ -44,6 +90,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_provider_namespace, # type: str @@ -68,28 +115,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,4 +139,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_providers_operations.py index 567794b0732ae..18f47a6937aff 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_providers_operations.py @@ -5,24 +5,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_at_management_group_scope_request( + resource_provider_namespace, # type: str + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +301,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +322,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +345,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register_at_management_group_scope( self, resource_provider_namespace, # type: str @@ -123,26 +373,16 @@ def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -155,6 +395,8 @@ def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -175,26 +417,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,8 +440,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -227,7 +462,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -235,38 +471,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,11 +515,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -306,7 +539,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -314,34 +548,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,11 +590,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -388,28 +621,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -423,8 +645,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -449,27 +674,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -483,4 +697,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resource_groups_operations.py index aace9f36d2d34..43444a81c56d9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resource_groups_operations.py @@ -5,26 +5,289 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +310,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +332,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +351,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +382,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +414,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -181,26 +429,16 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -213,6 +451,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -229,15 +469,17 @@ def begin_delete( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -250,20 +492,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -275,8 +511,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -298,26 +536,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +559,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -361,31 +592,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -399,8 +620,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -413,31 +636,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -453,8 +666,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -470,15 +686,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -489,26 +710,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -520,8 +736,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -538,8 +756,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -547,38 +767,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -596,6 +811,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resources_operations.py index 5f9df4954dbfa..ccc5a2c063bce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), + "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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1), - '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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,11 +961,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +974,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +1020,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -521,29 +1063,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -553,10 +1087,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -573,29 +1108,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,6 +1135,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -636,15 +1165,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -662,24 +1193,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -691,6 +1212,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -710,34 +1232,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -756,8 +1270,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -789,15 +1306,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -813,30 +1335,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -848,6 +1361,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -867,34 +1381,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -910,8 +1416,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -943,15 +1452,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -967,30 +1481,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1002,8 +1507,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1040,29 +1547,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1076,8 +1575,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1103,24 +1605,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,10 +1624,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1146,24 +1641,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1176,6 +1663,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1193,15 +1682,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1215,19 +1706,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1239,6 +1725,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1254,29 +1741,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1295,8 +1774,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1317,15 +1799,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1337,25 +1824,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1367,6 +1850,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1382,29 +1866,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1420,8 +1896,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1442,15 +1921,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2020_10_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1462,25 +1946,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1492,8 +1972,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1519,24 +2001,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,4 +2024,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_tags_operations.py index 0e7358b4f68a3..0103d213464c4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2020_10_01/operations/_tags_operations.py @@ -5,24 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + + +def build_create_or_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +361,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -72,27 +389,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +412,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -131,27 +440,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +468,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -196,26 +498,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -259,26 +554,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +576,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -305,7 +592,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -313,34 +601,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,11 +641,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace def create_or_update_at_scope( self, scope, # type: str @@ -389,30 +674,20 @@ def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,8 +701,11 @@ def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def update_at_scope( self, scope, # type: str @@ -458,30 +736,20 @@ def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,8 +763,11 @@ def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def get_at_scope( self, scope, # type: str @@ -519,25 +790,15 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,8 +812,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def delete_at_scope( self, scope, # type: str @@ -575,25 +839,15 @@ def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,3 +859,4 @@ def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py index 15e10bc228bd8..d5442c27b641a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json index 4439d0be5e666..e2e54687877ed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py index 3613698812c11..f65b207494066 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_resource_management_client.py @@ -6,29 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -36,79 +29,84 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2021_01_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2021_01_01.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_01_01.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2021_01_01.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2021_01_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2021_01_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2021_01_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2021_01_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2021_01_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py index 087a46ad28d16..c8fed08c4d50f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py index 4cf579edb1fe3..2e156f82a8ceb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/_resource_management_client.py @@ -6,105 +6,105 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2021_01_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2021_01_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2021_01_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py index 786cf495ab795..de795d223433a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py index 65ed90bb8bca1..fdeed8037d1c2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request_initial, build_validate_at_scope_request_initial, build_validate_at_subscription_scope_request_initial, build_validate_at_tenant_scope_request_initial, build_validate_request_initial, build_what_if_at_management_group_scope_request_initial, build_what_if_at_subscription_scope_request_initial, build_what_if_at_tenant_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,7 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_scope_initial( self, scope: str, @@ -468,31 +433,21 @@ async def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -511,8 +466,11 @@ async def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_scope( self, scope: str, @@ -531,15 +489,20 @@ async def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -551,26 +514,21 @@ async def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -582,8 +540,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -606,26 +566,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -639,8 +589,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -658,8 +611,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -667,38 +622,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -716,6 +666,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -731,25 +682,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,6 +703,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -781,15 +724,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -802,19 +747,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -826,8 +766,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -847,25 +789,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,10 +807,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -890,30 +823,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,8 +854,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -949,15 +875,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -968,25 +899,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -998,8 +925,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +948,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1051,8 +970,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1077,25 +999,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1108,6 +1020,7 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_tenant_scope_initial( self, deployment_name: str, @@ -1119,30 +1032,20 @@ async def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1161,8 +1064,11 @@ async def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_tenant_scope( self, deployment_name: str, @@ -1178,15 +1084,20 @@ async def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1197,25 +1108,21 @@ async def begin_validate_at_tenant_scope( raw_result = await self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1227,6 +1134,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_tenant_scope_initial( @@ -1240,30 +1148,20 @@ async def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,21 +1169,25 @@ async def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_tenant_scope( self, deployment_name: str, @@ -1301,15 +1203,20 @@ async def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1320,25 +1227,21 @@ async def begin_what_if_at_tenant_scope( raw_result = await self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1350,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1371,25 +1276,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1403,8 +1298,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1419,8 +1317,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1428,34 +1328,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1473,6 +1370,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1489,26 +1387,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1521,6 +1409,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1543,15 +1433,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1565,20 +1457,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1590,8 +1476,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1614,26 +1502,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1643,10 +1521,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1659,31 +1538,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1701,8 +1570,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1722,15 +1594,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1742,26 +1619,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1773,8 +1645,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1797,26 +1671,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1830,8 +1694,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1859,26 +1726,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1891,6 +1748,7 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_management_group_scope_initial( self, group_id: str, @@ -1903,31 +1761,21 @@ async def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1946,8 +1794,11 @@ async def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_management_group_scope( self, group_id: str, @@ -1966,15 +1817,20 @@ async def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1986,26 +1842,21 @@ async def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2017,6 +1868,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_management_group_scope_initial( @@ -2031,31 +1883,21 @@ async def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2063,21 +1905,25 @@ async def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_management_group_scope( self, group_id: str, @@ -2096,15 +1942,20 @@ async def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2116,26 +1967,21 @@ async def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2147,8 +1993,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -2171,26 +2019,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2204,8 +2042,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -2223,8 +2064,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2232,38 +2075,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2281,6 +2119,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2296,26 +2135,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2328,6 +2157,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -2347,15 +2178,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2368,20 +2201,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2393,8 +2220,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -2414,26 +2243,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2443,10 +2262,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2458,31 +2278,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2310,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2518,15 +2331,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2537,26 +2355,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2568,8 +2381,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2589,26 +2404,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2622,8 +2427,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2648,26 +2456,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2680,6 +2478,7 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_subscription_scope_initial( self, deployment_name: str, @@ -2691,31 +2490,21 @@ async def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2734,8 +2523,11 @@ async def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_subscription_scope( self, deployment_name: str, @@ -2751,15 +2543,20 @@ async def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2770,26 +2567,21 @@ async def begin_validate_at_subscription_scope( raw_result = await self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2801,6 +2593,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_subscription_scope_initial( @@ -2814,31 +2607,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2846,21 +2629,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2876,15 +2663,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2895,26 +2687,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2926,8 +2713,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2947,26 +2736,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2980,8 +2759,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2996,8 +2778,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3005,38 +2789,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3054,6 +2833,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3070,27 +2850,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3103,6 +2873,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -3127,15 +2899,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3149,21 +2923,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3175,8 +2942,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -3200,27 +2969,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3230,10 +2989,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -3246,32 +3006,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3289,8 +3039,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -3311,15 +3064,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3331,27 +3089,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3363,8 +3115,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -3387,27 +3141,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3421,8 +3165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -3450,27 +3197,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3483,6 +3220,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_initial( self, resource_group_name: str, @@ -3495,32 +3233,22 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3539,8 +3267,11 @@ async def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -3560,15 +3291,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3580,27 +3316,21 @@ async def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3612,6 +3342,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_initial( @@ -3626,32 +3357,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3659,21 +3380,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3693,15 +3418,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3713,27 +3443,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3745,8 +3469,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3769,27 +3495,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3803,8 +3519,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3823,8 +3542,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3832,39 +3553,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3882,11 +3599,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3906,26 +3625,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3939,4 +3651,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py index 3c99bef2d8530..ba0a312181481 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2021_01_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py index 4650265c662dc..c9e4a568b6eaa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_provider_resource_types_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._provider_resource_types_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_provider_namespace: str, @@ -63,28 +68,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,4 +92,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py index f6d141ffa83a1..b5e14b9131e8f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_register_at_management_group_scope_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register_at_management_group_scope( self, resource_provider_namespace: str, @@ -117,26 +116,16 @@ async def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -149,6 +138,8 @@ async def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -168,26 +159,16 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,8 +182,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, @@ -219,7 +203,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -227,38 +212,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -276,11 +256,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top: Optional[int] = None, @@ -297,7 +279,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -305,34 +288,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,11 +330,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -378,28 +360,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -413,8 +384,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -438,27 +412,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -472,4 +435,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py index b896d3d573670..0b18c6b813596 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -175,28 +165,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +188,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -229,15 +210,17 @@ async def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -251,20 +234,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -276,8 +253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -298,26 +277,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +300,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -360,31 +332,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -398,8 +360,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -411,31 +375,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -451,8 +405,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -467,15 +424,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -486,26 +448,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -517,8 +474,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -534,8 +493,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -543,38 +504,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -592,6 +548,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py index fb6b501aed720..f10b34040e1dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -407,11 +394,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -419,40 +407,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,11 +453,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -510,29 +495,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -542,10 +519,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -561,29 +539,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -596,6 +566,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -623,15 +595,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -649,24 +623,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -678,6 +642,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -696,34 +661,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -742,8 +699,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -774,15 +734,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,30 +763,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -833,6 +789,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -851,34 +808,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -894,8 +843,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -926,15 +878,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -950,30 +907,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -985,8 +933,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1022,29 +972,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1058,8 +1000,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1084,24 +1029,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1111,10 +1048,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1126,24 +1064,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1156,6 +1086,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1172,15 +1104,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1194,19 +1128,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1218,6 +1147,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1232,29 +1162,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1273,8 +1195,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1294,15 +1219,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1314,25 +1244,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1344,6 +1270,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1358,29 +1285,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1396,8 +1315,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1417,15 +1339,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1437,25 +1364,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1467,8 +1390,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1493,24 +1418,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1524,4 +1441,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py index f8df30e378782..5ce9d8156fd0c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_at_scope_request, build_create_or_update_request, build_create_or_update_value_request, build_delete_at_scope_request, build_delete_request, build_delete_value_request, build_get_at_scope_request, build_list_request, build_update_at_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -67,27 +73,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,6 +96,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -125,27 +123,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +151,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -189,26 +180,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +207,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -251,26 +235,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +257,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -296,7 +272,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -304,34 +281,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +321,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace_async async def create_or_update_at_scope( self, scope: str, @@ -379,30 +353,20 @@ async def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,8 +380,11 @@ async def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def update_at_scope( self, scope: str, @@ -447,30 +414,20 @@ async def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,8 +441,11 @@ async def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -507,25 +467,15 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,8 +489,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def delete_at_scope( self, scope: str, @@ -562,25 +515,15 @@ async def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -592,3 +535,4 @@ async def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py index ddf599b2f51fd..93eb940c67f3f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/__init__.py @@ -81,6 +81,7 @@ from ._models_py3 import WhatIfChange from ._models_py3 import WhatIfOperationResult from ._models_py3 import WhatIfPropertyChange + from ._models_py3 import ZoneMapping except (SyntaxError, ImportError): from ._models import Alias # type: ignore from ._models import AliasPath # type: ignore @@ -156,6 +157,7 @@ from ._models import WhatIfChange # type: ignore from ._models import WhatIfOperationResult # type: ignore from ._models import WhatIfPropertyChange # type: ignore + from ._models import ZoneMapping # type: ignore from ._resource_management_client_enums import ( AliasPathAttributes, @@ -250,6 +252,7 @@ 'WhatIfChange', 'WhatIfOperationResult', 'WhatIfPropertyChange', + 'ZoneMapping', 'AliasPathAttributes', 'AliasPathTokenType', 'AliasPatternType', diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py index db85b967a1d03..c79928b6f7578 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -130,12 +153,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType """ _attribute_map = { @@ -148,6 +171,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -179,6 +210,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -187,12 +220,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -205,6 +238,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -214,13 +255,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -231,6 +272,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -238,14 +288,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -259,6 +309,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -271,12 +331,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -293,6 +353,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -302,8 +370,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -314,6 +382,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -329,13 +401,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -357,6 +429,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -369,8 +450,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -381,6 +462,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -390,8 +475,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -409,6 +494,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -423,8 +512,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties """ @@ -443,6 +532,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -511,6 +605,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -529,8 +625,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -548,6 +644,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -558,38 +658,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions """ @@ -612,6 +713,42 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -715,6 +852,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -742,8 +881,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended """ @@ -760,6 +899,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) @@ -770,10 +914,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { @@ -789,6 +934,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -799,41 +951,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings """ @@ -857,6 +1010,45 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -864,9 +1056,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat """ @@ -878,6 +1070,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -907,6 +1105,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -950,6 +1150,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -961,13 +1163,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -979,6 +1181,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -987,9 +1198,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1001,6 +1212,12 @@ def __init__( self, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = kwargs.get('scope', None) @@ -1008,10 +1225,10 @@ def __init__( class ExtendedLocation(msrest.serialization.Model): """Resource extended location. - :param type: The extended location type. Possible values include: "EdgeZone". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType - :param name: The extended location name. - :type name: str + :ivar type: The extended location type. Possible values include: "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :ivar name: The extended location name. + :vartype name: str """ _attribute_map = { @@ -1023,6 +1240,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: The extended location type. Possible values include: "EdgeZone". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :keyword name: The extended location name. + :paramtype name: str + """ super(ExtendedLocation, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) @@ -1039,12 +1262,12 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1066,6 +1289,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1086,24 +1318,24 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity """ _validation = { @@ -1132,6 +1364,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -1152,24 +1405,24 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1213,6 +1466,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1222,12 +1496,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1240,6 +1514,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1249,8 +1531,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1261,6 +1543,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1274,13 +1560,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1300,6 +1586,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.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.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1332,6 +1628,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1340,11 +1638,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1356,6 +1654,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1368,11 +1673,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1389,6 +1694,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1398,10 +1710,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay """ _attribute_map = { @@ -1413,6 +1725,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1421,14 +1739,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1442,6 +1760,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1452,10 +1780,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1467,6 +1795,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1477,10 +1811,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1496,6 +1830,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1504,16 +1844,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1528,6 +1868,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1543,8 +1895,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1573,6 +1925,10 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1584,12 +1940,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1602,6 +1958,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.type = kwargs.get('type', None) @@ -1613,8 +1977,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1632,6 +1996,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1642,25 +2010,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_01_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1675,6 +2045,7 @@ class ProviderResourceType(msrest.serialization.Model): 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, @@ -1684,6 +2055,25 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1691,6 +2081,7 @@ def __init__( self.aliases = kwargs.get('aliases', None) self.api_versions = kwargs.get('api_versions', None) self.default_api_version = None + self.zone_mappings = kwargs.get('zone_mappings', None) self.api_profiles = None self.capabilities = kwargs.get('capabilities', None) self.properties = kwargs.get('properties', None) @@ -1701,8 +2092,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1720,6 +2111,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1738,15 +2133,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1770,6 +2165,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1783,10 +2190,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ _attribute_map = { @@ -1798,6 +2205,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1806,10 +2219,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1821,6 +2234,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1831,8 +2250,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1850,6 +2269,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1858,14 +2281,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1879,6 +2302,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1907,6 +2341,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -1916,8 +2352,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1935,6 +2371,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1943,16 +2384,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -1967,6 +2408,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1996,6 +2449,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2003,10 +2458,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2018,6 +2473,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -2028,12 +2489,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2051,6 +2512,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2062,10 +2531,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2082,6 +2552,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2090,18 +2567,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2117,6 +2594,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -2129,10 +2620,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ _attribute_map = { @@ -2144,6 +2635,12 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2152,8 +2649,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2164,6 +2661,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -2171,10 +2672,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2186,6 +2687,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -2198,13 +2705,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] """ _validation = { @@ -2222,6 +2729,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -2232,8 +2748,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2244,6 +2760,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -2253,8 +2773,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2272,6 +2792,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2280,11 +2804,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _attribute_map = { @@ -2296,6 +2820,14 @@ def __init__( self, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) @@ -2314,8 +2846,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _validation = { @@ -2336,6 +2868,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2350,10 +2886,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount """ _validation = { @@ -2370,6 +2906,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -2379,12 +2921,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2397,6 +2939,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -2406,10 +2956,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2421,6 +2971,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -2429,20 +2985,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2457,6 +3013,24 @@ def __init__( self, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs.get('uri', None) self.id = kwargs.get('id', None) @@ -2470,20 +3044,20 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify", "Unsupported". - :type change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType - :param unsupported_reason: The explanation about why the resource is unsupported by What-If. - :type unsupported_reason: str - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. + :vartype unsupported_reason: str + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { @@ -2504,6 +3078,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. + :paramtype unsupported_reason: str + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2516,12 +3106,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] """ _attribute_map = { @@ -2534,6 +3124,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2545,18 +3143,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array", "NoEffect". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { @@ -2576,9 +3174,53 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] self.before = kwargs.get('before', None) self.after = kwargs.get('after', None) self.children = kwargs.get('children', None) + + +class ZoneMapping(msrest.serialization.Model): + """ZoneMapping. + + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ + super(ZoneMapping, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py index 61fd5439970b9..a64a665be8a9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_models_py3.py @@ -18,17 +18,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata @@ -57,6 +57,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2021_01_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -71,12 +84,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPathMetadata @@ -101,6 +114,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -197,6 +228,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -205,12 +238,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -227,6 +260,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -236,13 +277,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -255,6 +296,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -262,14 +312,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -288,6 +338,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2021_01_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -300,12 +360,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -326,6 +386,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -335,8 +403,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -349,6 +417,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -364,13 +436,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -396,6 +468,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -408,8 +489,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -422,6 +503,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -431,8 +516,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -452,6 +537,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -466,8 +555,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties """ @@ -488,6 +577,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -556,6 +650,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -574,8 +670,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -595,6 +691,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -605,38 +705,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions """ @@ -668,6 +769,42 @@ def __init__( expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -771,6 +908,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -798,8 +937,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended """ @@ -818,6 +957,11 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties @@ -828,10 +972,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { @@ -850,6 +995,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -860,41 +1012,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings """ @@ -928,6 +1081,45 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_01_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_01_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_01_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) self.what_if_settings = what_if_settings @@ -935,9 +1127,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat """ @@ -951,6 +1143,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -980,6 +1178,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1023,6 +1223,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1034,13 +1236,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -1055,6 +1257,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -1063,9 +1274,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1079,6 +1290,12 @@ def __init__( scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = scope @@ -1086,10 +1303,10 @@ def __init__( class ExtendedLocation(msrest.serialization.Model): """Resource extended location. - :param type: The extended location type. Possible values include: "EdgeZone". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType - :param name: The extended location name. - :type name: str + :ivar type: The extended location type. Possible values include: "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :ivar name: The extended location name. + :vartype name: str """ _attribute_map = { @@ -1104,6 +1321,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword type: The extended location type. Possible values include: "EdgeZone". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocationType + :keyword name: The extended location name. + :paramtype name: str + """ super(ExtendedLocation, self).__init__(**kwargs) self.type = type self.name = name @@ -1120,12 +1343,12 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1151,6 +1374,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1171,24 +1403,24 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity """ _validation = { @@ -1227,6 +1459,27 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ super(GenericResource, self).__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1247,24 +1500,24 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1318,6 +1571,27 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_01_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_01_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_01_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_01_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, extended_location=extended_location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1327,12 +1601,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1349,6 +1623,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1358,8 +1640,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1372,6 +1654,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1385,13 +1671,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1414,6 +1700,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.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.resource.resources.v2021_01_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1446,6 +1742,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1454,11 +1752,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1473,6 +1771,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1485,11 +1790,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1509,6 +1814,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1518,10 +1830,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay """ _attribute_map = { @@ -1536,6 +1848,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2021_01_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1544,14 +1862,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1570,6 +1888,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1580,10 +1908,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1598,6 +1926,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1608,10 +1942,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1630,6 +1964,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1638,16 +1978,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1668,6 +2008,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1683,8 +2035,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1715,6 +2067,10 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1726,12 +2082,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1748,6 +2104,14 @@ def __init__( extended_locations: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = location self.type = type @@ -1759,8 +2123,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1780,6 +2144,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1790,25 +2158,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_01_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1823,6 +2193,7 @@ class ProviderResourceType(msrest.serialization.Model): 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, @@ -1836,10 +2207,30 @@ def __init__( location_mappings: Optional[List["ProviderExtendedLocation"]] = None, aliases: Optional[List["Alias"]] = None, api_versions: Optional[List[str]] = None, + zone_mappings: Optional[List["ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2021_01_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2021_01_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1847,6 +2238,7 @@ def __init__( self.aliases = aliases self.api_versions = api_versions self.default_api_version = None + self.zone_mappings = zone_mappings self.api_profiles = None self.capabilities = capabilities self.properties = properties @@ -1857,8 +2249,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1878,6 +2270,10 @@ def __init__( value: Optional[List["ProviderResourceType"]] = None, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1896,15 +2292,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1933,6 +2329,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1946,10 +2354,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ _attribute_map = { @@ -1964,6 +2372,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -1972,10 +2386,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1990,6 +2404,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -2000,8 +2420,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2021,6 +2441,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2029,14 +2453,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2055,6 +2479,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -2083,6 +2518,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -2092,8 +2529,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2113,6 +2550,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2121,16 +2563,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -2151,6 +2593,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -2180,6 +2634,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2187,10 +2643,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2205,6 +2661,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -2215,12 +2677,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2242,6 +2704,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2253,10 +2723,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2276,6 +2747,13 @@ def __init__( properties: "DeploymentWhatIfProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2284,18 +2762,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2318,6 +2796,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2330,10 +2822,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse """ _attribute_map = { @@ -2348,6 +2840,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = status self.error = error @@ -2356,8 +2854,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2370,6 +2868,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -2377,10 +2879,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2395,6 +2897,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -2407,13 +2915,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] """ _validation = { @@ -2435,6 +2943,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2445,8 +2962,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2459,6 +2976,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags @@ -2468,8 +2989,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2489,6 +3010,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_01_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2497,11 +3022,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _attribute_map = { @@ -2516,6 +3041,14 @@ def __init__( properties: Optional["Tags"] = None, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties @@ -2534,8 +3067,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags """ _validation = { @@ -2558,6 +3091,10 @@ def __init__( properties: "Tags", **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_01_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2572,10 +3109,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount """ _validation = { @@ -2595,6 +3132,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2021_01_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2604,12 +3147,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2626,6 +3169,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2635,10 +3186,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2653,6 +3204,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2661,20 +3218,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2695,6 +3252,24 @@ def __init__( query_string: Optional[str] = None, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.id = id @@ -2708,20 +3283,20 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify", "Unsupported". - :type change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType - :param unsupported_reason: The explanation about why the resource is unsupported by What-If. - :type unsupported_reason: str - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. + :vartype unsupported_reason: str + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { @@ -2749,6 +3324,22 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.ChangeType + :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. + :paramtype unsupported_reason: str + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2761,12 +3352,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] """ _attribute_map = { @@ -2783,6 +3374,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2021_01_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2794,18 +3393,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array", "NoEffect". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] """ _validation = { @@ -2831,9 +3430,56 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2021_01_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before self.after = after self.children = children + + +class ZoneMapping(msrest.serialization.Model): + """ZoneMapping. + + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + zones: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ + super(ZoneMapping, self).__init__(**kwargs) + self.location = location + self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py index de30896c2196a..aa2b114ef29b6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -101,7 +86,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The resource is not supported by What-If. UNSUPPORTED = "Unsupported" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -112,7 +97,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -121,13 +106,13 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMe OUTER = "Outer" INNER = "Inner" -class ExtendedLocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The extended location type. """ EDGE_ZONE = "EdgeZone" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -135,7 +120,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -153,7 +138,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property will not be set or updated. NO_EFFECT = "NoEffect" -class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the current provisioning operation. """ @@ -179,7 +164,7 @@ class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Denotes the state of provisioning. """ @@ -196,7 +181,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -205,7 +190,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation type for the patch API. """ @@ -217,7 +202,7 @@ class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py index b26f10985eb9b..bb8c573091484 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py index 1449cb1330908..59b80698e0db5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_deployments_operations.py @@ -5,26 +5,1637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1670,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1692,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1717,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1741,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -161,8 +1760,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1787,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1806,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1824,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1856,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1881,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1906,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -347,8 +1932,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1959,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1982,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +2015,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +2037,7 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_scope_initial( self, scope, # type: str @@ -480,31 +2051,21 @@ def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,8 +2084,11 @@ def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_scope( self, scope, # type: str @@ -544,15 +2108,20 @@ def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -564,26 +2133,21 @@ def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -595,8 +2159,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -620,26 +2186,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +2209,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -673,8 +2232,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -682,38 +2243,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -731,6 +2287,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -747,25 +2304,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -778,6 +2325,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -798,15 +2347,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -819,19 +2370,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -843,8 +2389,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -865,25 +2413,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -893,10 +2431,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -909,30 +2448,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,8 +2479,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -969,15 +2501,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -988,25 +2525,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1018,8 +2551,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2575,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1072,8 +2597,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1099,25 +2627,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,6 +2648,7 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_tenant_scope_initial( self, deployment_name, # type: str @@ -1142,30 +2661,20 @@ def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1184,8 +2693,11 @@ def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_tenant_scope( self, deployment_name, # type: str @@ -1202,15 +2714,20 @@ def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1221,25 +2738,21 @@ def begin_validate_at_tenant_scope( raw_result = self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1251,6 +2764,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_tenant_scope_initial( @@ -1265,30 +2779,20 @@ def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1296,21 +2800,25 @@ def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_tenant_scope( self, deployment_name, # type: str @@ -1327,15 +2835,20 @@ def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1346,25 +2859,21 @@ def begin_what_if_at_tenant_scope( raw_result = self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1376,8 +2885,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1398,25 +2909,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +2931,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1447,8 +2951,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1456,34 +2962,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1501,6 +3004,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1518,26 +3022,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,6 +3044,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1573,15 +3069,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1595,20 +3093,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1620,8 +3112,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1645,26 +3139,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1674,10 +3158,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1691,31 +3176,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1733,8 +3208,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1755,15 +3233,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1775,26 +3258,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1806,8 +3284,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1831,26 +3311,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1864,8 +3334,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1894,26 +3367,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1926,6 +3389,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_management_group_scope_initial( self, group_id, # type: str @@ -1939,31 +3403,21 @@ def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1982,8 +3436,11 @@ def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_management_group_scope( self, group_id, # type: str @@ -2003,15 +3460,20 @@ def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2023,26 +3485,21 @@ def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2054,6 +3511,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_management_group_scope_initial( @@ -2069,31 +3527,21 @@ def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2101,21 +3549,25 @@ def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_management_group_scope( self, group_id, # type: str @@ -2135,15 +3587,20 @@ def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2155,26 +3612,21 @@ def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2186,8 +3638,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -2211,26 +3665,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2244,8 +3688,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -2264,8 +3711,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2273,38 +3722,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2322,6 +3766,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2338,26 +3783,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2370,6 +3805,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -2390,15 +3827,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2411,20 +3850,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2436,8 +3869,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2458,26 +3893,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2487,10 +3912,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2503,31 +3929,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3961,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2564,15 +3983,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2583,26 +4007,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2614,8 +4033,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2636,26 +4057,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2669,8 +4080,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2696,26 +4110,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2728,6 +4132,7 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2740,31 +4145,21 @@ def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2783,8 +4178,11 @@ def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_subscription_scope( self, deployment_name, # type: str @@ -2801,15 +4199,20 @@ def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2820,26 +4223,21 @@ def begin_validate_at_subscription_scope( raw_result = self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2851,6 +4249,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_subscription_scope_initial( @@ -2865,31 +4264,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2897,21 +4286,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2928,15 +4321,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2947,26 +4345,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2978,8 +4371,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -3000,26 +4395,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3033,8 +4418,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -3050,8 +4438,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3059,38 +4449,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3108,6 +4493,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3125,27 +4511,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3158,6 +4534,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -3183,15 +4561,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3205,21 +4585,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3231,8 +4604,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -3257,27 +4632,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3287,10 +4652,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -3304,32 +4670,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3347,8 +4703,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -3370,15 +4729,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3390,27 +4754,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3422,8 +4780,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -3447,27 +4807,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3481,8 +4831,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3511,27 +4864,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3544,6 +4887,7 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_initial( self, resource_group_name, # type: str @@ -3557,32 +4901,22 @@ def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3601,8 +4935,11 @@ def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate( self, resource_group_name, # type: str @@ -3623,15 +4960,20 @@ def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3643,27 +4985,21 @@ def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3675,6 +5011,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( @@ -3690,32 +5027,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3723,21 +5050,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3758,15 +5089,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3778,27 +5114,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3810,8 +5140,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3835,27 +5167,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3869,8 +5191,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3890,8 +5215,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3899,39 +5226,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3949,11 +5272,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3974,26 +5299,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -4007,4 +5325,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py index 0fac2d4b51acd..7bec339068e55 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2021_01_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py index a14b8bef6b86e..bc5e781416bae 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_provider_resource_types_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProviderResourceTypesOperations(object): """ProviderResourceTypesOperations operations. @@ -44,6 +90,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_provider_namespace, # type: str @@ -68,28 +115,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,4 +139,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py index e350642d052e2..ae967138d58df 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_providers_operations.py @@ -5,24 +5,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_at_management_group_scope_request( + resource_provider_namespace, # type: str + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +301,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +322,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +345,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register_at_management_group_scope( self, resource_provider_namespace, # type: str @@ -123,26 +373,16 @@ def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -155,6 +395,8 @@ def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -175,26 +417,16 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,8 +440,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, top=None, # type: Optional[int] @@ -227,7 +462,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -235,38 +471,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + top=top, + expand=expand, + 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, + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,11 +515,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, top=None, # type: Optional[int] @@ -306,7 +539,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -314,34 +548,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + top=top, + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + top=top, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,11 +590,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -388,28 +621,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -423,8 +645,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -449,27 +674,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -483,4 +697,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py index 5f63bba78680c..ddb9d56a0f44e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resource_groups_operations.py @@ -5,26 +5,293 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + force_deletion_types = kwargs.pop('force_deletion_types', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + if force_deletion_types is not None: + query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, '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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +314,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +336,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +355,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +386,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +418,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -182,28 +434,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,6 +457,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -237,15 +480,17 @@ def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -259,20 +504,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -284,8 +523,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -307,26 +548,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,8 +571,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -370,31 +604,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -408,8 +632,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -422,31 +648,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -462,8 +678,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -479,15 +698,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -498,26 +722,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -529,8 +748,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -547,8 +768,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -556,38 +779,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,6 +823,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py index c00fff15d4d2d..3d3fd1f8da34c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -417,11 +961,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +974,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +1020,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -521,29 +1063,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -553,10 +1087,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -573,29 +1108,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -608,6 +1135,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -636,15 +1165,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -662,24 +1193,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -691,6 +1212,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -710,34 +1232,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -756,8 +1270,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -789,15 +1306,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -813,30 +1335,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -848,6 +1361,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -867,34 +1381,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -910,8 +1416,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -943,15 +1452,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -967,30 +1481,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1002,8 +1507,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1040,29 +1547,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1076,8 +1575,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1103,24 +1605,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,10 +1624,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1146,24 +1641,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1176,6 +1663,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1193,15 +1682,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1215,19 +1706,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1239,6 +1725,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1254,29 +1741,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1295,8 +1774,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1317,15 +1799,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1337,25 +1824,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1367,6 +1850,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1382,29 +1866,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1420,8 +1896,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1442,15 +1921,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_01_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1462,25 +1946,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1492,8 +1972,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1519,24 +2001,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,4 +2024,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py index 99f9f87384d15..1d73cb78b9ea7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_01_01/operations/_tags_operations.py @@ -5,24 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + + +def build_create_or_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +361,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -72,27 +389,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +412,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -131,27 +440,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +468,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -196,26 +498,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -259,26 +554,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +576,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -305,7 +592,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_01_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -313,34 +601,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,11 +641,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace def create_or_update_at_scope( self, scope, # type: str @@ -389,30 +674,20 @@ def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,8 +701,11 @@ def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def update_at_scope( self, scope, # type: str @@ -458,30 +736,20 @@ def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,8 +763,11 @@ def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def get_at_scope( self, scope, # type: str @@ -519,25 +790,15 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,8 +812,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def delete_at_scope( self, scope, # type: str @@ -575,25 +839,15 @@ def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,3 +859,4 @@ def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py index d5207c07d07e5..449220069f2f2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceManagementClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py index b3747e4713762..78176cdf56ee7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json index f192689c5d40f..4e3af46969e98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ResourceManagementClient", "filename": "_resource_management_client", "description": "Provides operations for working with resources and resource groups.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py index 10fa738df74a5..cde2323bf70a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_resource_management_client.py @@ -6,29 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. @@ -36,79 +29,84 @@ class ResourceManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2021_04_01.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2021_04_01.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2021_04_01.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2021_04_01.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_04_01.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2021_04_01.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2021_04_01.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2021_04_01.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2021_04_01.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2021_04_01.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2021_04_01.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2021_04_01.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Microsoft Azure subscription ID. :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py index f11762bdb19bb..c6c3cf64a37a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_management_client import ResourceManagementClient __all__ = ['ResourceManagementClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py index 495f5a469f46c..5427f0941ac4f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ResourceManagementClientConfiguration, 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(ResourceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py index dbf12e75e7f6b..e84d09d87e6a8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/_resource_management_client.py @@ -6,105 +6,105 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceManagementClientConfiguration +from .operations import DeploymentOperationsOperations, DeploymentsOperations, Operations, ProviderResourceTypesOperations, ProvidersOperations, ResourceGroupsOperations, ResourcesOperations, TagsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceManagementClientConfiguration -from .operations import Operations -from .operations import DeploymentsOperations -from .operations import ProvidersOperations -from .operations import ProviderResourceTypesOperations -from .operations import ResourcesOperations -from .operations import ResourceGroupsOperations -from .operations import TagsOperations -from .operations import DeploymentOperationsOperations -from .. import models - - -class ResourceManagementClient(object): +class ResourceManagementClient: """Provides operations for working with resources and resource groups. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2021_04_01.aio.operations.Operations :ivar deployments: DeploymentsOperations operations - :vartype deployments: azure.mgmt.resource.resources.v2021_04_01.aio.operations.DeploymentsOperations + :vartype deployments: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.DeploymentsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.mgmt.resource.resources.v2021_04_01.aio.operations.ProvidersOperations + :vartype providers: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.ProvidersOperations :ivar provider_resource_types: ProviderResourceTypesOperations operations - :vartype provider_resource_types: azure.mgmt.resource.resources.v2021_04_01.aio.operations.ProviderResourceTypesOperations + :vartype provider_resource_types: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.ProviderResourceTypesOperations :ivar resources: ResourcesOperations operations - :vartype resources: azure.mgmt.resource.resources.v2021_04_01.aio.operations.ResourcesOperations + :vartype resources: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.ResourcesOperations :ivar resource_groups: ResourceGroupsOperations operations - :vartype resource_groups: azure.mgmt.resource.resources.v2021_04_01.aio.operations.ResourceGroupsOperations + :vartype resource_groups: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.ResourceGroupsOperations :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2021_04_01.aio.operations.TagsOperations :ivar deployment_operations: DeploymentOperationsOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2021_04_01.aio.operations.DeploymentOperationsOperations + :vartype deployment_operations: + azure.mgmt.resource.resources.v2021_04_01.aio.operations.DeploymentOperationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Microsoft Azure subscription ID. :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 = ResourceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ResourceManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_resource_types = ProviderResourceTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resources = ResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_groups = ResourceGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_resource_types = ProviderResourceTypesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resources = ResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_groups = ResourceGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployment_operations_operations.py index a79b2bc344868..820aba222d35b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployment_operations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployment_operations_operations import build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -66,27 +72,17 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -118,8 +117,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -127,37 +128,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,11 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -202,26 +201,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -235,8 +224,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name: str, @@ -250,8 +242,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -259,36 +253,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -306,11 +295,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -336,27 +327,17 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -370,8 +351,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -388,8 +372,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -397,37 +383,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,11 +427,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -472,27 +456,17 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -506,8 +480,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name: str, @@ -521,8 +498,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -530,37 +509,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -578,11 +553,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -608,28 +585,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -643,8 +610,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -661,8 +631,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -670,38 +642,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -719,6 +688,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployments_operations.py index db533e6df80d4..a5becbea7f090 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_deployments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deployments_operations import build_calculate_template_hash_request, build_cancel_at_management_group_scope_request, build_cancel_at_scope_request, build_cancel_at_subscription_scope_request, build_cancel_at_tenant_scope_request, build_cancel_request, build_check_existence_at_management_group_scope_request, build_check_existence_at_scope_request, build_check_existence_at_subscription_scope_request, build_check_existence_at_tenant_scope_request, build_check_existence_request, build_create_or_update_at_management_group_scope_request_initial, build_create_or_update_at_scope_request_initial, build_create_or_update_at_subscription_scope_request_initial, build_create_or_update_at_tenant_scope_request_initial, build_create_or_update_request_initial, build_delete_at_management_group_scope_request_initial, build_delete_at_scope_request_initial, build_delete_at_subscription_scope_request_initial, build_delete_at_tenant_scope_request_initial, build_delete_request_initial, build_export_template_at_management_group_scope_request, build_export_template_at_scope_request, build_export_template_at_subscription_scope_request, build_export_template_at_tenant_scope_request, build_export_template_request, build_get_at_management_group_scope_request, build_get_at_scope_request, build_get_at_subscription_scope_request, build_get_at_tenant_scope_request, build_get_request, build_list_at_management_group_scope_request, build_list_at_scope_request, build_list_at_subscription_scope_request, build_list_at_tenant_scope_request, build_list_by_resource_group_request, build_validate_at_management_group_scope_request_initial, build_validate_at_scope_request_initial, build_validate_at_subscription_scope_request_initial, build_validate_at_tenant_scope_request_initial, build_validate_request_initial, build_what_if_at_management_group_scope_request_initial, build_what_if_at_subscription_scope_request_initial, build_what_if_at_tenant_scope_request_initial, build_what_if_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,26 +59,16 @@ async def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -86,6 +81,8 @@ async def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_scope( self, scope: str, @@ -108,15 +105,17 @@ async def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -130,20 +129,14 @@ async def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -155,8 +148,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_scope( self, scope: str, @@ -179,26 +174,16 @@ async def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,10 +193,11 @@ async def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_scope_initial( self, scope: str, @@ -224,31 +210,21 @@ async def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +242,11 @@ async def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_scope( self, scope: str, @@ -287,15 +266,20 @@ async def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -307,26 +291,21 @@ async def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -338,8 +317,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -362,26 +343,16 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +366,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_scope( self, scope: str, @@ -424,26 +398,16 @@ async def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -456,6 +420,7 @@ async def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_scope_initial( self, scope: str, @@ -468,31 +433,21 @@ async def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -511,8 +466,11 @@ async def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_scope( self, scope: str, @@ -531,15 +489,20 @@ async def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -551,26 +514,21 @@ async def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -582,8 +540,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace_async async def export_template_at_scope( self, scope: str, @@ -606,26 +566,16 @@ async def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -639,8 +589,11 @@ async def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope: str, @@ -658,8 +611,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -667,38 +622,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -716,6 +666,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -731,25 +682,15 @@ async def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -762,6 +703,8 @@ async def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_tenant_scope( self, deployment_name: str, @@ -781,15 +724,17 @@ async def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -802,19 +747,14 @@ async def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -826,8 +766,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_tenant_scope( self, deployment_name: str, @@ -847,25 +789,15 @@ async def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -875,10 +807,11 @@ async def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_tenant_scope_initial( self, deployment_name: str, @@ -890,30 +823,20 @@ async def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -931,8 +854,11 @@ async def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_tenant_scope( self, deployment_name: str, @@ -949,15 +875,20 @@ async def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -968,25 +899,21 @@ async def begin_create_or_update_at_tenant_scope( raw_result = await self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -998,8 +925,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_tenant_scope( self, deployment_name: str, @@ -1019,25 +948,15 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1051,8 +970,11 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_tenant_scope( self, deployment_name: str, @@ -1077,25 +999,15 @@ async def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1108,6 +1020,7 @@ async def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_tenant_scope_initial( self, deployment_name: str, @@ -1119,30 +1032,20 @@ async def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1161,8 +1064,11 @@ async def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_tenant_scope( self, deployment_name: str, @@ -1178,15 +1084,20 @@ async def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1197,25 +1108,21 @@ async def begin_validate_at_tenant_scope( raw_result = await self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1227,6 +1134,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_tenant_scope_initial( @@ -1240,30 +1148,20 @@ async def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1271,21 +1169,25 @@ async def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_tenant_scope( self, deployment_name: str, @@ -1301,15 +1203,20 @@ async def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1320,25 +1227,21 @@ async def begin_what_if_at_tenant_scope( raw_result = await self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1350,8 +1253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_tenant_scope( self, deployment_name: str, @@ -1371,25 +1276,15 @@ async def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1403,8 +1298,11 @@ async def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter: Optional[str] = None, @@ -1419,8 +1317,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1428,34 +1328,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1473,6 +1370,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -1489,26 +1387,16 @@ async def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1521,6 +1409,8 @@ async def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_management_group_scope( self, group_id: str, @@ -1543,15 +1433,17 @@ async def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1565,20 +1457,14 @@ async def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1590,8 +1476,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_management_group_scope( self, group_id: str, @@ -1614,26 +1502,16 @@ async def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1643,10 +1521,11 @@ async def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_management_group_scope_initial( self, group_id: str, @@ -1659,31 +1538,21 @@ async def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1701,8 +1570,11 @@ async def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_management_group_scope( self, group_id: str, @@ -1722,15 +1594,20 @@ async def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1742,26 +1619,21 @@ async def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1773,8 +1645,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_management_group_scope( self, group_id: str, @@ -1797,26 +1671,16 @@ async def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1830,8 +1694,11 @@ async def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_management_group_scope( self, group_id: str, @@ -1859,26 +1726,16 @@ async def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1891,6 +1748,7 @@ async def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_management_group_scope_initial( self, group_id: str, @@ -1903,31 +1761,21 @@ async def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1946,8 +1794,11 @@ async def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_management_group_scope( self, group_id: str, @@ -1966,15 +1817,20 @@ async def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1986,26 +1842,21 @@ async def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2017,6 +1868,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_management_group_scope_initial( @@ -2031,31 +1883,21 @@ async def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2063,21 +1905,25 @@ async def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_management_group_scope( self, group_id: str, @@ -2096,15 +1942,20 @@ async def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2116,26 +1967,21 @@ async def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2147,8 +1993,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_management_group_scope( self, group_id: str, @@ -2171,26 +2019,16 @@ async def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2204,8 +2042,11 @@ async def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id: str, @@ -2223,8 +2064,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2232,38 +2075,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2281,6 +2119,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -2296,26 +2135,16 @@ async def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2328,6 +2157,8 @@ async def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete_at_subscription_scope( self, deployment_name: str, @@ -2347,15 +2178,17 @@ async def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2368,20 +2201,14 @@ async def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2393,8 +2220,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence_at_subscription_scope( self, deployment_name: str, @@ -2414,26 +2243,16 @@ async def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2443,10 +2262,11 @@ async def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_at_subscription_scope_initial( self, deployment_name: str, @@ -2458,31 +2278,21 @@ async def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2500,8 +2310,11 @@ async def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_at_subscription_scope( self, deployment_name: str, @@ -2518,15 +2331,20 @@ async def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2537,26 +2355,21 @@ async def begin_create_or_update_at_subscription_scope( raw_result = await self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2568,8 +2381,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get_at_subscription_scope( self, deployment_name: str, @@ -2589,26 +2404,16 @@ async def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2622,8 +2427,11 @@ async def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel_at_subscription_scope( self, deployment_name: str, @@ -2648,26 +2456,16 @@ async def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2680,6 +2478,7 @@ async def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_at_subscription_scope_initial( self, deployment_name: str, @@ -2691,31 +2490,21 @@ async def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2734,8 +2523,11 @@ async def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate_at_subscription_scope( self, deployment_name: str, @@ -2751,15 +2543,20 @@ async def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2770,26 +2567,21 @@ async def begin_validate_at_subscription_scope( raw_result = await self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2801,6 +2593,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_at_subscription_scope_initial( @@ -2814,31 +2607,21 @@ async def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2846,21 +2629,25 @@ async def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if_at_subscription_scope( self, deployment_name: str, @@ -2876,15 +2663,20 @@ async def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2895,26 +2687,21 @@ async def begin_what_if_at_subscription_scope( raw_result = await self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -2926,8 +2713,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template_at_subscription_scope( self, deployment_name: str, @@ -2947,26 +2736,16 @@ async def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2980,8 +2759,11 @@ async def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter: Optional[str] = None, @@ -2996,8 +2778,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3005,38 +2789,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3054,6 +2833,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -3070,27 +2850,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3103,6 +2873,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -3127,15 +2899,17 @@ async def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3149,21 +2923,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3175,8 +2942,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -3200,27 +2969,17 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3230,10 +2989,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -3246,32 +3006,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3289,8 +3039,11 @@ 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.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -3311,15 +3064,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3331,27 +3089,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3363,8 +3115,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -3387,27 +3141,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3421,8 +3165,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, @@ -3450,27 +3197,17 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3483,6 +3220,7 @@ async def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + async def _validate_initial( self, resource_group_name: str, @@ -3495,32 +3233,22 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3539,8 +3267,11 @@ async def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -3560,15 +3291,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3580,27 +3316,21 @@ async def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3612,6 +3342,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore async def _what_if_initial( @@ -3626,32 +3357,22 @@ async def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3659,21 +3380,25 @@ async def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace_async async def begin_what_if( self, resource_group_name: str, @@ -3693,15 +3418,20 @@ async def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3713,27 +3443,21 @@ async def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -3745,8 +3469,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace_async async def export_template( self, resource_group_name: str, @@ -3769,27 +3495,17 @@ async def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3803,8 +3519,11 @@ async def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -3823,8 +3542,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3832,39 +3553,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3882,11 +3599,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace_async async def calculate_template_hash( self, template: Any, @@ -3906,26 +3625,19 @@ async def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3939,4 +3651,6 @@ async def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py index 78b0d9cd9edea..cb97ed0549180 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.resources.v2021_04_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_provider_resource_types_operations.py index 2a0cbbdfcbe0e..6f4a1139f85f9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_provider_resource_types_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._provider_resource_types_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_provider_namespace: str, @@ -63,28 +68,17 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,4 +92,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py index f40003d622977..e8fb30eb8c169 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_providers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_at_tenant_scope_request, build_get_request, build_list_at_tenant_scope_request, build_list_request, build_provider_permissions_request, build_register_at_management_group_scope_request, build_register_request, build_unregister_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def unregister( self, resource_provider_namespace: str, @@ -60,26 +66,16 @@ async def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -93,8 +89,11 @@ async def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace_async async def register_at_management_group_scope( self, resource_provider_namespace: str, @@ -117,26 +116,16 @@ async def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -149,6 +138,8 @@ async def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace_async async def provider_permissions( self, resource_provider_namespace: str, @@ -168,26 +159,16 @@ async def provider_permissions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.provider_permissions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_provider_permissions_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.provider_permissions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -201,8 +182,11 @@ async def provider_permissions( return cls(pipeline_response, deserialized, {}) return deserialized + provider_permissions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions'} # type: ignore + + @distributed_trace_async async def register( self, resource_provider_namespace: str, @@ -225,34 +209,24 @@ async def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if properties is not None: - body_content = self._serialize.body(properties, 'ProviderRegistrationRequest') + _json = self._serialize.body(properties, 'ProviderRegistrationRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -266,8 +240,11 @@ async def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, expand: Optional[str] = None, @@ -281,7 +258,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -289,36 +267,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -336,11 +309,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, expand: Optional[str] = None, @@ -354,7 +329,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -362,32 +338,29 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -405,11 +378,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -433,28 +408,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -468,8 +432,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace_async async def get_at_tenant_scope( self, resource_provider_namespace: str, @@ -493,27 +460,16 @@ async def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -527,4 +483,6 @@ async def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resource_groups_operations.py index ea1745a33a55a..b05a33ccc79c0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resource_groups_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_groups_operations import build_check_existence_request, build_create_or_update_request, build_delete_request_initial, build_export_template_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -63,26 +69,16 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -92,10 +88,12 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -120,31 +118,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -162,8 +150,10 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -175,28 +165,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -209,6 +188,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -229,15 +210,17 @@ async def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -251,20 +234,14 @@ async def begin_delete( 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 = { - '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'), - } - 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: @@ -276,8 +253,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -298,26 +277,16 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -331,8 +300,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -360,31 +332,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -398,8 +360,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + async def _export_template_initial( self, resource_group_name: str, @@ -411,31 +375,21 @@ async def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -451,8 +405,11 @@ async def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace_async async def begin_export_template( self, resource_group_name: str, @@ -467,15 +424,20 @@ async def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -486,26 +448,21 @@ async def begin_export_template( raw_result = await self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -517,8 +474,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -534,8 +493,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -543,38 +504,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -592,6 +548,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py index c8938fee764c7..e5f1e85ce6701 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_resources_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resources_operations import build_check_existence_by_id_request, build_check_existence_request, build_create_or_update_by_id_request_initial, build_create_or_update_request_initial, build_delete_by_id_request_initial, build_delete_request_initial, build_get_by_id_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_move_resources_request_initial, build_update_by_id_request_initial, build_update_request_initial, build_validate_move_resources_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -74,11 +80,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -86,41 +93,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,6 +141,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -154,31 +158,21 @@ async def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,6 +185,8 @@ async def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace_async async def begin_move_resources( self, source_resource_group_name: str, @@ -211,15 +207,18 @@ async def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -230,23 +229,18 @@ async def begin_move_resources( raw_result = await self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -258,6 +252,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore async def _validate_move_resources_initial( @@ -271,31 +266,21 @@ async def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -308,6 +293,8 @@ async def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace_async async def begin_validate_move_resources( self, source_resource_group_name: str, @@ -330,15 +317,18 @@ async def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -349,23 +339,18 @@ async def begin_validate_move_resources( raw_result = await self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -377,8 +362,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -399,15 +386,16 @@ def list( currently-supported properties: ``name`` and ``resourceGroup``\ :code:`
`:code:`
`For example, to get all resources with 'demo' anywhere in the resource name, use ``$filter=substringof('demo', name)``\ :code:`
`:code:`
`Multiple substring operations - can also be combined using ``and``\ /\ ``or`` - operators.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and - values. For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and - tagValue eq 'Value1'``. Note that when resources are filtered by tag name and value, - :code:`the original tags for each resource will not be returned in the results.` Any - list of additional properties queried via ``$expand`` may also not be compatible when filtering - by tag names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by - prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will - return all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , + can also be combined using ``and``\ /\ ``or`` operators.:code:`
`:code:`
`Note that any + truncated number of results queried via ``$top`` may also not be compatible when using a + filter.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and values. + For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and tagValue + eq 'Value1'``. Note that when resources are filtered by tag name and value, :code:`the + original tags for each resource will not be returned in the results.` Any list of + additional properties queried via ``$expand`` may also not be compatible when filtering by tag + names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by prefix + using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will return + all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , ``departureDate``\ , ``departureTime``\ , etc.):code:`
`:code:`
`:code:`
`Note that some properties can be combined when filtering resources, which include the following: ``substringof() and/or resourceType``\ , ``plan and plan/publisher and plan/name``\ , and @@ -417,11 +405,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -429,40 +418,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,11 +464,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace_async async def check_existence( self, resource_group_name: str, @@ -520,29 +506,21 @@ async def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -552,10 +530,11 @@ async def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -571,29 +550,21 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -606,6 +577,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -633,15 +606,17 @@ async def begin_delete( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -659,24 +634,14 @@ async def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -688,6 +653,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _create_or_update_initial( @@ -706,34 +672,26 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -752,8 +710,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -784,15 +745,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -808,30 +774,21 @@ async def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -843,6 +800,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore async def _update_initial( @@ -861,34 +819,26 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -904,8 +854,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -936,15 +889,20 @@ async def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -960,30 +918,21 @@ async def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -995,8 +944,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -1032,29 +983,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1068,8 +1011,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace_async async def check_existence_by_id( self, resource_id: str, @@ -1094,24 +1040,16 @@ async def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1121,10 +1059,11 @@ async def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + async def _delete_by_id_initial( self, resource_id: str, @@ -1136,24 +1075,16 @@ async def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1166,6 +1097,8 @@ async def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_delete_by_id( self, resource_id: str, @@ -1182,15 +1115,17 @@ async def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1204,19 +1139,14 @@ async def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1228,6 +1158,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _create_or_update_by_id_initial( @@ -1242,29 +1173,21 @@ async def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1283,8 +1206,11 @@ async def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_by_id( self, resource_id: str, @@ -1304,15 +1230,20 @@ async def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1324,25 +1255,21 @@ async def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1354,6 +1281,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore async def _update_by_id_initial( @@ -1368,29 +1296,21 @@ async def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1406,8 +1326,11 @@ async def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace_async async def begin_update_by_id( self, resource_id: str, @@ -1427,15 +1350,20 @@ async def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1447,25 +1375,21 @@ async def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1477,8 +1401,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace_async async def get_by_id( self, resource_id: str, @@ -1503,24 +1429,16 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1534,4 +1452,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_tags_operations.py index 162a607fdfe4d..f81a9891b77b2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/aio/operations/_tags_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_create_or_update_at_scope_request, build_create_or_update_request, build_create_or_update_value_request, build_delete_at_scope_request, build_delete_request, build_delete_value_request, build_get_at_scope_request, build_list_request, build_update_at_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete_value( self, tag_name: str, @@ -67,27 +73,17 @@ async def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,6 +96,8 @@ async def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update_value( self, tag_name: str, @@ -125,27 +123,17 @@ async def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -163,8 +151,11 @@ async def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, tag_name: str, @@ -189,26 +180,16 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -226,8 +207,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace_async async def delete( self, tag_name: str, @@ -251,26 +235,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -283,6 +257,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -296,7 +272,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -304,34 +281,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,11 +321,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace_async async def create_or_update_at_scope( self, scope: str, @@ -379,30 +353,20 @@ async def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -416,8 +380,11 @@ async def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def update_at_scope( self, scope: str, @@ -447,30 +414,20 @@ async def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -484,8 +441,11 @@ async def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def get_at_scope( self, scope: str, @@ -507,25 +467,15 @@ async def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,8 +489,11 @@ async def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace_async async def delete_at_scope( self, scope: str, @@ -562,25 +515,15 @@ async def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -592,3 +535,4 @@ async def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py index 448b8f5efce2a..6ca28dd652e00 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/__init__.py @@ -87,6 +87,7 @@ from ._models_py3 import WhatIfChange from ._models_py3 import WhatIfOperationResult from ._models_py3 import WhatIfPropertyChange + from ._models_py3 import ZoneMapping except (SyntaxError, ImportError): from ._models import Alias # type: ignore from ._models import AliasPath # type: ignore @@ -168,6 +169,7 @@ from ._models import WhatIfChange # type: ignore from ._models import WhatIfOperationResult # type: ignore from ._models import WhatIfPropertyChange # type: ignore + from ._models import ZoneMapping # type: ignore from ._resource_management_client_enums import ( AliasPathAttributes, @@ -269,6 +271,7 @@ 'WhatIfChange', 'WhatIfOperationResult', 'WhatIfPropertyChange', + 'ZoneMapping', 'AliasPathAttributes', 'AliasPathTokenType', 'AliasPatternType', diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models.py index 780af0ee0cd8c..139feec2a6b17 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models.py @@ -14,17 +14,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathMetadata @@ -47,6 +47,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) @@ -61,12 +74,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathMetadata @@ -87,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -130,12 +153,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType """ _attribute_map = { @@ -148,6 +171,14 @@ def __init__( self, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) @@ -179,6 +210,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -187,12 +220,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -205,6 +238,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) @@ -214,13 +255,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -231,6 +272,15 @@ def __init__( self, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) @@ -238,14 +288,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -259,6 +309,16 @@ def __init__( self, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -271,12 +331,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -293,6 +353,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -302,8 +370,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -314,6 +382,10 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) @@ -329,13 +401,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -357,6 +429,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -369,8 +450,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -381,6 +462,10 @@ def __init__( self, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) @@ -390,8 +475,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -409,6 +494,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -423,8 +512,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationProperties """ @@ -443,6 +532,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -511,6 +605,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -529,8 +625,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -548,6 +644,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -558,38 +658,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions """ @@ -612,6 +713,42 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) @@ -715,6 +852,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -742,8 +881,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended """ @@ -760,6 +899,11 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) @@ -770,10 +914,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { @@ -789,6 +934,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.properties = kwargs['properties'] @@ -799,41 +951,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfSettings """ @@ -857,6 +1010,45 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) @@ -864,9 +1056,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat """ @@ -878,6 +1070,12 @@ def __init__( self, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) @@ -907,6 +1105,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -950,6 +1150,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -961,13 +1163,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -979,6 +1181,15 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) @@ -987,9 +1198,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1001,6 +1212,12 @@ def __init__( self, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = kwargs.get('scope', None) @@ -1008,10 +1225,10 @@ def __init__( class ExtendedLocation(msrest.serialization.Model): """Resource extended location. - :param type: The extended location type. Possible values include: "EdgeZone". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType - :param name: The extended location name. - :type name: str + :ivar type: The extended location type. Possible values include: "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType + :ivar name: The extended location name. + :vartype name: str """ _attribute_map = { @@ -1023,6 +1240,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: The extended location type. Possible values include: "EdgeZone". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType + :keyword name: The extended location name. + :paramtype name: str + """ super(ExtendedLocation, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) @@ -1039,12 +1262,12 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1066,6 +1289,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1086,24 +1318,24 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity """ _validation = { @@ -1132,6 +1364,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + """ super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -1152,24 +1405,24 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1213,6 +1466,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None @@ -1222,12 +1496,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1240,6 +1514,14 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) @@ -1249,8 +1531,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1261,6 +1543,10 @@ def __init__( self, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) @@ -1274,13 +1560,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_04_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1300,6 +1586,16 @@ def __init__( self, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.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.resource.resources.v2021_04_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1332,6 +1628,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1340,11 +1638,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1356,6 +1654,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) @@ -1368,11 +1673,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1389,6 +1694,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) @@ -1398,10 +1710,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay """ _attribute_map = { @@ -1413,6 +1725,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1421,14 +1739,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1442,6 +1760,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1452,10 +1780,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1467,6 +1795,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1477,10 +1811,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1496,6 +1830,12 @@ def __init__( self, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) @@ -1504,14 +1844,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -1525,6 +1865,16 @@ def __init__( self, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = kwargs.get('actions', None) self.not_actions = kwargs.get('not_actions', None) @@ -1535,16 +1885,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1559,6 +1909,18 @@ def __init__( self, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1574,8 +1936,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1583,9 +1945,9 @@ class Provider(msrest.serialization.Model): :ivar resource_types: The collection of provider resource types. :vartype resource_types: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] - :param provider_authorization_consent_state: The provider authorization consent state. Possible + :ivar provider_authorization_consent_state: The provider authorization consent state. Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". - :type provider_authorization_consent_state: str or + :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ @@ -1609,6 +1971,14 @@ def __init__( self, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + :keyword provider_authorization_consent_state: The provider authorization consent state. + Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :paramtype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1621,8 +1991,8 @@ def __init__( class ProviderConsentDefinition(msrest.serialization.Model): """The provider consent. - :param consent_to_authorization: A value indicating whether authorization is consented or not. - :type consent_to_authorization: bool + :ivar consent_to_authorization: A value indicating whether authorization is consented or not. + :vartype consent_to_authorization: bool """ _attribute_map = { @@ -1633,6 +2003,11 @@ def __init__( self, **kwargs ): + """ + :keyword consent_to_authorization: A value indicating whether authorization is consented or + not. + :paramtype consent_to_authorization: bool + """ super(ProviderConsentDefinition, self).__init__(**kwargs) self.consent_to_authorization = kwargs.get('consent_to_authorization', None) @@ -1640,12 +2015,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1658,6 +2033,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.type = kwargs.get('type', None) @@ -1669,8 +2052,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1688,6 +2071,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1696,16 +2083,16 @@ def __init__( class ProviderPermission(msrest.serialization.Model): """The provider permission. - :param application_id: The application id. - :type application_id: str - :param role_definition: Role definition properties. - :type role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :param managed_by_role_definition: Role definition properties. - :type managed_by_role_definition: + :ivar application_id: The application id. + :vartype application_id: str + :ivar role_definition: Role definition properties. + :vartype role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :ivar managed_by_role_definition: Role definition properties. + :vartype managed_by_role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :param provider_authorization_consent_state: The provider authorization consent state. Possible + :ivar provider_authorization_consent_state: The provider authorization consent state. Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". - :type provider_authorization_consent_state: str or + :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ @@ -1720,6 +2107,19 @@ def __init__( self, **kwargs ): + """ + :keyword application_id: The application id. + :paramtype application_id: str + :keyword role_definition: Role definition properties. + :paramtype role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :keyword managed_by_role_definition: Role definition properties. + :paramtype managed_by_role_definition: + ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :keyword provider_authorization_consent_state: The provider authorization consent state. + Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :paramtype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState + """ super(ProviderPermission, self).__init__(**kwargs) self.application_id = kwargs.get('application_id', None) self.role_definition = kwargs.get('role_definition', None) @@ -1732,8 +2132,8 @@ class ProviderPermissionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of provider permissions. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] + :ivar value: An array of provider permissions. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1751,6 +2151,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of provider permissions. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] + """ super(ProviderPermissionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1759,8 +2163,8 @@ def __init__( class ProviderRegistrationRequest(msrest.serialization.Model): """The provider registration definition. - :param third_party_provider_consent: The provider consent. - :type third_party_provider_consent: + :ivar third_party_provider_consent: The provider consent. + :vartype third_party_provider_consent: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderConsentDefinition """ @@ -1772,6 +2176,11 @@ def __init__( self, **kwargs ): + """ + :keyword third_party_provider_consent: The provider consent. + :paramtype third_party_provider_consent: + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderConsentDefinition + """ super(ProviderRegistrationRequest, self).__init__(**kwargs) self.third_party_provider_consent = kwargs.get('third_party_provider_consent', None) @@ -1781,25 +2190,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_04_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1814,6 +2225,7 @@ class ProviderResourceType(msrest.serialization.Model): 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, @@ -1823,6 +2235,25 @@ def __init__( self, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1830,6 +2261,7 @@ def __init__( self.aliases = kwargs.get('aliases', None) self.api_versions = kwargs.get('api_versions', None) self.default_api_version = None + self.zone_mappings = kwargs.get('zone_mappings', None) self.api_profiles = None self.capabilities = kwargs.get('capabilities', None) self.properties = kwargs.get('properties', None) @@ -1840,8 +2272,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1859,6 +2291,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1877,15 +2313,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -1909,6 +2345,18 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1922,10 +2370,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ _attribute_map = { @@ -1937,6 +2385,12 @@ def __init__( self, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) @@ -1945,10 +2399,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -1960,6 +2414,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) @@ -1970,8 +2430,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1989,6 +2449,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -1997,14 +2461,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2018,6 +2482,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -2046,6 +2521,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -2055,8 +2532,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2074,6 +2551,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2082,16 +2564,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -2106,6 +2588,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -2135,6 +2629,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2142,10 +2638,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2157,6 +2653,12 @@ def __init__( self, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) @@ -2165,16 +2667,16 @@ def __init__( class RoleDefinition(msrest.serialization.Model): """Role definition properties. - :param id: The role definition ID. - :type id: str - :param name: The role definition name. - :type name: str - :param is_service_role: If this is a service role. - :type is_service_role: bool - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] - :param scopes: Role definition assignable scopes. - :type scopes: list[str] + :ivar id: The role definition ID. + :vartype id: str + :ivar name: The role definition name. + :vartype name: str + :ivar is_service_role: If this is a service role. + :vartype is_service_role: bool + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] + :ivar scopes: Role definition assignable scopes. + :vartype scopes: list[str] """ _attribute_map = { @@ -2189,6 +2691,18 @@ def __init__( self, **kwargs ): + """ + :keyword id: The role definition ID. + :paramtype id: str + :keyword name: The role definition name. + :paramtype name: str + :keyword is_service_role: If this is a service role. + :paramtype is_service_role: bool + :keyword permissions: Role definition permissions. + :paramtype permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] + :keyword scopes: Role definition assignable scopes. + :paramtype scopes: list[str] + """ super(RoleDefinition, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -2202,12 +2716,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2225,6 +2739,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2236,10 +2758,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2256,6 +2779,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs['location'] self.properties = kwargs['properties'] @@ -2264,18 +2794,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2291,6 +2821,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -2303,10 +2847,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ _attribute_map = { @@ -2318,6 +2862,12 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2326,8 +2876,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2338,6 +2888,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -2345,10 +2899,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2360,6 +2914,12 @@ def __init__( self, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) @@ -2372,13 +2932,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] """ _validation = { @@ -2396,6 +2956,15 @@ def __init__( self, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -2406,8 +2975,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2418,6 +2987,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -2427,8 +3000,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2446,6 +3019,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -2454,11 +3031,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _attribute_map = { @@ -2470,6 +3047,14 @@ def __init__( self, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) @@ -2488,8 +3073,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _validation = { @@ -2510,6 +3095,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2524,10 +3113,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount """ _validation = { @@ -2544,6 +3133,12 @@ def __init__( self, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) @@ -2553,12 +3148,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2571,6 +3166,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) @@ -2580,10 +3183,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2595,6 +3198,12 @@ def __init__( self, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) @@ -2603,20 +3212,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2631,6 +3240,24 @@ def __init__( self, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = kwargs.get('uri', None) self.id = kwargs.get('id', None) @@ -2644,20 +3271,20 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify", "Unsupported". - :type change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType - :param unsupported_reason: The explanation about why the resource is unsupported by What-If. - :type unsupported_reason: str - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType + :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. + :vartype unsupported_reason: str + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { @@ -2678,6 +3305,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType + :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. + :paramtype unsupported_reason: str + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = kwargs['resource_id'] self.change_type = kwargs['change_type'] @@ -2690,12 +3333,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] """ _attribute_map = { @@ -2708,6 +3351,14 @@ def __init__( self, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) self.error = kwargs.get('error', None) @@ -2719,18 +3370,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array", "NoEffect". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { @@ -2750,9 +3401,53 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = kwargs['path'] self.property_change_type = kwargs['property_change_type'] self.before = kwargs.get('before', None) self.after = kwargs.get('after', None) self.children = kwargs.get('children', None) + + +class ZoneMapping(msrest.serialization.Model): + """ZoneMapping. + + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ + super(ZoneMapping, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.zones = kwargs.get('zones', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py index 5950198074461..c00a82795685b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_models_py3.py @@ -18,17 +18,17 @@ class Alias(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The alias name. - :type name: str - :param paths: The paths for an alias. - :type paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] - :param type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + :ivar name: The alias name. + :vartype name: str + :ivar paths: The paths for an alias. + :vartype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] + :ivar type: The type of the alias. Possible values include: "NotSpecified", "PlainText", "Mask". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType - :param default_path: The default path for an alias. - :type default_path: str - :param default_pattern: The default pattern for an alias. - :type default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType + :ivar default_path: The default path for an alias. + :vartype default_path: str + :ivar default_pattern: The default pattern for an alias. + :vartype default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern :ivar default_metadata: The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata. :vartype default_metadata: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathMetadata @@ -57,6 +57,19 @@ def __init__( default_pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword name: The alias name. + :paramtype name: str + :keyword paths: The paths for an alias. + :paramtype paths: list[~azure.mgmt.resource.resources.v2021_04_01.models.AliasPath] + :keyword type: The type of the alias. Possible values include: "NotSpecified", "PlainText", + "Mask". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasType + :keyword default_path: The default path for an alias. + :paramtype default_path: str + :keyword default_pattern: The default pattern for an alias. + :paramtype default_pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + """ super(Alias, self).__init__(**kwargs) self.name = name self.paths = paths @@ -71,12 +84,12 @@ class AliasPath(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param path: The path of an alias. - :type path: str - :param api_versions: The API versions. - :type api_versions: list[str] - :param pattern: The pattern for an alias path. - :type pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + :ivar path: The path of an alias. + :vartype path: str + :ivar api_versions: The API versions. + :vartype api_versions: list[str] + :ivar pattern: The pattern for an alias path. + :vartype pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern :ivar metadata: The metadata of the alias path. If missing, fall back to the default metadata of the alias. :vartype metadata: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPathMetadata @@ -101,6 +114,14 @@ def __init__( pattern: Optional["AliasPattern"] = None, **kwargs ): + """ + :keyword path: The path of an alias. + :paramtype path: str + :keyword api_versions: The API versions. + :paramtype api_versions: list[str] + :keyword pattern: The pattern for an alias path. + :paramtype pattern: ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPattern + """ super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions @@ -136,6 +157,8 @@ def __init__( self, **kwargs ): + """ + """ super(AliasPathMetadata, self).__init__(**kwargs) self.type = None self.attributes = None @@ -144,12 +167,12 @@ def __init__( class AliasPattern(msrest.serialization.Model): """The type of the pattern for an alias path. - :param phrase: The alias pattern phrase. - :type phrase: str - :param variable: The alias pattern variable. - :type variable: str - :param type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType + :ivar phrase: The alias pattern phrase. + :vartype phrase: str + :ivar variable: The alias pattern variable. + :vartype variable: str + :ivar type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType """ _attribute_map = { @@ -166,6 +189,14 @@ def __init__( type: Optional[Union[str, "AliasPatternType"]] = None, **kwargs ): + """ + :keyword phrase: The alias pattern phrase. + :paramtype phrase: str + :keyword variable: The alias pattern variable. + :paramtype variable: str + :keyword type: The type of alias pattern. Possible values include: "NotSpecified", "Extract". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.AliasPatternType + """ super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable @@ -197,6 +228,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiProfile, self).__init__(**kwargs) self.profile_version = None self.api_version = None @@ -205,12 +238,12 @@ def __init__( class BasicDependency(msrest.serialization.Model): """Deployment dependency information. - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -227,6 +260,14 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type @@ -236,13 +277,13 @@ def __init__( class DebugSetting(msrest.serialization.Model): """The debug setting. - :param detail_level: Specifies the type of information to log for debugging. The permitted + :ivar detail_level: Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, or both requestContent and responseContent separated by a comma. The default is none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging information about the request or response, you could potentially expose sensitive data that is retrieved through the deployment operations. - :type detail_level: str + :vartype detail_level: str """ _attribute_map = { @@ -255,6 +296,15 @@ def __init__( detail_level: Optional[str] = None, **kwargs ): + """ + :keyword detail_level: Specifies the type of information to log for debugging. The permitted + values are none, requestContent, responseContent, or both requestContent and responseContent + separated by a comma. The default is none. When setting this value, carefully consider the type + of information you are passing in during deployment. By logging information about the request + or response, you could potentially expose sensitive data that is retrieved through the + deployment operations. + :paramtype detail_level: str + """ super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level @@ -262,14 +312,14 @@ def __init__( class Dependency(msrest.serialization.Model): """Deployment dependency information. - :param depends_on: The list of dependencies. - :type depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] - :param id: The ID of the dependency. - :type id: str - :param resource_type: The dependency resource type. - :type resource_type: str - :param resource_name: The dependency resource name. - :type resource_name: str + :ivar depends_on: The list of dependencies. + :vartype depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] + :ivar id: The ID of the dependency. + :vartype id: str + :ivar resource_type: The dependency resource type. + :vartype resource_type: str + :ivar resource_name: The dependency resource name. + :vartype resource_name: str """ _attribute_map = { @@ -288,6 +338,16 @@ def __init__( resource_name: Optional[str] = None, **kwargs ): + """ + :keyword depends_on: The list of dependencies. + :paramtype depends_on: list[~azure.mgmt.resource.resources.v2021_04_01.models.BasicDependency] + :keyword id: The ID of the dependency. + :paramtype id: str + :keyword resource_type: The dependency resource type. + :paramtype resource_type: str + :keyword resource_name: The dependency resource name. + :paramtype resource_name: str + """ super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -300,12 +360,12 @@ class Deployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -326,6 +386,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -335,8 +403,8 @@ def __init__( class DeploymentExportResult(msrest.serialization.Model): """The deployment export result. - :param template: The template content. - :type template: any + :ivar template: The template content. + :vartype template: any """ _attribute_map = { @@ -349,6 +417,10 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + """ super(DeploymentExportResult, self).__init__(**kwargs) self.template = template @@ -364,13 +436,13 @@ class DeploymentExtended(msrest.serialization.Model): :vartype name: str :ivar type: The type of the deployment. :vartype type: str - :param location: the location of the deployment. - :type location: str - :param properties: Deployment properties. - :type properties: + :ivar location: the location of the deployment. + :vartype location: str + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -396,6 +468,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: the location of the deployment. + :paramtype location: str + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -408,8 +489,8 @@ def __init__( class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. - :param provisioning_state: The provisioning state. - :type provisioning_state: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _attribute_map = { @@ -422,6 +503,10 @@ def __init__( provisioning_state: Optional[str] = None, **kwargs ): + """ + :keyword provisioning_state: The provisioning state. + :paramtype provisioning_state: str + """ super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -431,8 +516,8 @@ class DeploymentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployments. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :ivar value: An array of deployments. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -452,6 +537,10 @@ def __init__( value: Optional[List["DeploymentExtended"]] = None, **kwargs ): + """ + :keyword value: An array of deployments. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + """ super(DeploymentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -466,8 +555,8 @@ class DeploymentOperation(msrest.serialization.Model): :vartype id: str :ivar operation_id: Deployment operation ID. :vartype operation_id: str - :param properties: Deployment properties. - :type properties: + :ivar properties: Deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationProperties """ @@ -488,6 +577,11 @@ def __init__( properties: Optional["DeploymentOperationProperties"] = None, **kwargs ): + """ + :keyword properties: Deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationProperties + """ super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None @@ -556,6 +650,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_operation = None self.provisioning_state = None @@ -574,8 +670,8 @@ class DeploymentOperationsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of deployment operations. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + :ivar value: An array of deployment operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -595,6 +691,10 @@ def __init__( value: Optional[List["DeploymentOperation"]] = None, **kwargs ): + """ + :keyword value: An array of deployment operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperation] + """ super(DeploymentOperationsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -605,38 +705,39 @@ class DeploymentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions """ @@ -668,6 +769,42 @@ def __init__( expression_evaluation_options: Optional["ExpressionEvaluationOptions"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions + """ super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -771,6 +908,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -798,8 +937,8 @@ class DeploymentValidateResult(msrest.serialization.Model): :ivar error: The deployment validation error. :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse - :param properties: The template deployment properties. - :type properties: + :ivar properties: The template deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended """ @@ -818,6 +957,11 @@ def __init__( properties: Optional["DeploymentPropertiesExtended"] = None, **kwargs ): + """ + :keyword properties: The template deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentPropertiesExtended + """ super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties @@ -828,10 +972,11 @@ class DeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + :ivar location: The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { @@ -850,6 +995,13 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + """ super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -860,41 +1012,42 @@ class DeploymentWhatIfProperties(DeploymentProperties): All required parameters must be populated in order to send to Azure. - :param template: The template content. You use this element when you want to pass the template + :ivar template: The template content. You use this element when you want to pass the template syntax directly in the request rather than link to an existing template. It can be a JObject or well-formed JSON string. Use either the templateLink property or the template property, but not both. - :type template: any - :param template_link: The URI of the template. Use either the templateLink property or the + :vartype template: any + :ivar template_link: The URI of the template. Use either the templateLink property or the template property, but not both. - :type template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink - :param parameters: Name and value pairs that define the deployment parameters for the template. + :vartype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :ivar parameters: Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide the parameter values directly in the request rather than link to an existing parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed JSON string. - :type parameters: any - :param parameters_link: The URI of parameters file. You use this element to link to an existing + :vartype parameters: any + :ivar parameters_link: The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink property or the parameters property, but not both. - :type parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink - :param mode: Required. The mode that is used to deploy resources. This value can be either + :vartype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :ivar mode: Required. The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included in the template are deleted. Be careful when using Complete mode as you may unintentionally delete resources. Possible values include: "Incremental", "Complete". - :type mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode - :param debug_setting: The debug setting of the deployment. - :type debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting - :param on_error_deployment: The deployment on error behavior. - :type on_error_deployment: ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment - :param expression_evaluation_options: Specifies whether template expressions are evaluated + :vartype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :ivar debug_setting: The debug setting of the deployment. + :vartype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :ivar on_error_deployment: The deployment on error behavior. + :vartype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :ivar expression_evaluation_options: Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable to nested templates. If not specified, default value is outer. - :type expression_evaluation_options: + :vartype expression_evaluation_options: ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions - :param what_if_settings: Optional What-If operation settings. - :type what_if_settings: + :ivar what_if_settings: Optional What-If operation settings. + :vartype what_if_settings: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfSettings """ @@ -928,6 +1081,45 @@ def __init__( what_if_settings: Optional["DeploymentWhatIfSettings"] = None, **kwargs ): + """ + :keyword template: The template content. You use this element when you want to pass the + template syntax directly in the request rather than link to an existing template. It can be a + JObject or well-formed JSON string. Use either the templateLink property or the template + property, but not both. + :paramtype template: any + :keyword template_link: The URI of the template. Use either the templateLink property or the + template property, but not both. + :paramtype template_link: ~azure.mgmt.resource.resources.v2021_04_01.models.TemplateLink + :keyword parameters: Name and value pairs that define the deployment parameters for the + template. You use this element when you want to provide the parameter values directly in the + request rather than link to an existing parameter file. Use either the parametersLink property + or the parameters property, but not both. It can be a JObject or a well formed JSON string. + :paramtype parameters: any + :keyword parameters_link: The URI of parameters file. You use this element to link to an + existing parameters file. Use either the parametersLink property or the parameters property, + but not both. + :paramtype parameters_link: ~azure.mgmt.resource.resources.v2021_04_01.models.ParametersLink + :keyword mode: Required. The mode that is used to deploy resources. This value can be either + Incremental or Complete. In Incremental mode, resources are deployed without deleting existing + resources that are not included in the template. In Complete mode, resources are deployed and + existing resources in the resource group that are not included in the template are deleted. Be + careful when using Complete mode as you may unintentionally delete resources. Possible values + include: "Incremental", "Complete". + :paramtype mode: str or ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentMode + :keyword debug_setting: The debug setting of the deployment. + :paramtype debug_setting: ~azure.mgmt.resource.resources.v2021_04_01.models.DebugSetting + :keyword on_error_deployment: The deployment on error behavior. + :paramtype on_error_deployment: + ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeployment + :keyword expression_evaluation_options: Specifies whether template expressions are evaluated + within the scope of the parent template or nested template. Only applicable to nested + templates. If not specified, default value is outer. + :paramtype expression_evaluation_options: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptions + :keyword what_if_settings: Optional What-If operation settings. + :paramtype what_if_settings: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfSettings + """ super(DeploymentWhatIfProperties, self).__init__(template=template, template_link=template_link, parameters=parameters, parameters_link=parameters_link, mode=mode, debug_setting=debug_setting, on_error_deployment=on_error_deployment, expression_evaluation_options=expression_evaluation_options, **kwargs) self.what_if_settings = what_if_settings @@ -935,9 +1127,9 @@ def __init__( class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values include: + :ivar result_format: The format of the What-If results. Possible values include: "ResourceIdOnly", "FullResourcePayloads". - :type result_format: str or + :vartype result_format: str or ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat """ @@ -951,6 +1143,12 @@ def __init__( result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, **kwargs ): + """ + :keyword result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". + :paramtype result_format: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfResultFormat + """ super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format @@ -980,6 +1178,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1023,6 +1223,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -1034,13 +1236,13 @@ def __init__( class ExportTemplateRequest(msrest.serialization.Model): """Export resource group template request parameters. - :param resources: The IDs of the resources to filter the export by. To export all resources, + :ivar resources: The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. - :type resources: list[str] - :param options: The export template options. A CSV-formatted list containing zero or more of - the following: 'IncludeParameterDefaultValue', 'IncludeComments', + :vartype resources: list[str] + :ivar options: The export template options. A CSV-formatted list containing zero or more of the + following: 'IncludeParameterDefaultValue', 'IncludeComments', 'SkipResourceNameParameterization', 'SkipAllParameterization'. - :type options: str + :vartype options: str """ _attribute_map = { @@ -1055,6 +1257,15 @@ def __init__( options: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources to filter the export by. To export all resources, + supply an array with single entry '*'. + :paramtype resources: list[str] + :keyword options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :paramtype options: str + """ super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options @@ -1063,9 +1274,9 @@ def __init__( class ExpressionEvaluationOptions(msrest.serialization.Model): """Specifies whether template expressions are evaluated within the scope of the parent template or nested template. - :param scope: The scope to be used for evaluation of parameters, variables and functions in a + :ivar scope: The scope to be used for evaluation of parameters, variables and functions in a nested template. Possible values include: "NotSpecified", "Outer", "Inner". - :type scope: str or + :vartype scope: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType """ @@ -1079,6 +1290,12 @@ def __init__( scope: Optional[Union[str, "ExpressionEvaluationOptionsScopeType"]] = None, **kwargs ): + """ + :keyword scope: The scope to be used for evaluation of parameters, variables and functions in a + nested template. Possible values include: "NotSpecified", "Outer", "Inner". + :paramtype scope: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ExpressionEvaluationOptionsScopeType + """ super(ExpressionEvaluationOptions, self).__init__(**kwargs) self.scope = scope @@ -1086,10 +1303,10 @@ def __init__( class ExtendedLocation(msrest.serialization.Model): """Resource extended location. - :param type: The extended location type. Possible values include: "EdgeZone". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType - :param name: The extended location name. - :type name: str + :ivar type: The extended location type. Possible values include: "EdgeZone". + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType + :ivar name: The extended location name. + :vartype name: str """ _attribute_map = { @@ -1104,6 +1321,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword type: The extended location type. Possible values include: "EdgeZone". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocationType + :keyword name: The extended location name. + :paramtype name: str + """ super(ExtendedLocation, self).__init__(**kwargs) self.type = type self.name = name @@ -1120,12 +1343,12 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1151,6 +1374,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1171,24 +1403,24 @@ class GenericResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity """ _validation = { @@ -1227,6 +1459,27 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + """ super(GenericResource, self).__init__(location=location, extended_location=extended_location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -1247,24 +1500,24 @@ class GenericResourceExpanded(GenericResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param extended_location: Resource extended location. - :type extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: The plan of the resource. - :type plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan - :param properties: The resource properties. - :type properties: any - :param kind: The kind of the resource. - :type kind: str - :param managed_by: ID of the resource that manages this resource. - :type managed_by: str - :param sku: The SKU of the resource. - :type sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar extended_location: Resource extended location. + :vartype extended_location: ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: The plan of the resource. + :vartype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :ivar properties: The resource properties. + :vartype properties: any + :ivar kind: The kind of the resource. + :vartype kind: str + :ivar managed_by: ID of the resource that manages this resource. + :vartype managed_by: str + :ivar sku: The SKU of the resource. + :vartype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity :ivar created_time: The created time of the resource. This is only present if requested via the $expand query parameter. :vartype created_time: ~datetime.datetime @@ -1318,6 +1571,27 @@ def __init__( identity: Optional["Identity"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword extended_location: Resource extended location. + :paramtype extended_location: + ~azure.mgmt.resource.resources.v2021_04_01.models.ExtendedLocation + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: The plan of the resource. + :paramtype plan: ~azure.mgmt.resource.resources.v2021_04_01.models.Plan + :keyword properties: The resource properties. + :paramtype properties: any + :keyword kind: The kind of the resource. + :paramtype kind: str + :keyword managed_by: ID of the resource that manages this resource. + :paramtype managed_by: str + :keyword sku: The SKU of the resource. + :paramtype sku: ~azure.mgmt.resource.resources.v2021_04_01.models.Sku + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.resource.resources.v2021_04_01.models.Identity + """ super(GenericResourceExpanded, self).__init__(location=location, extended_location=extended_location, tags=tags, plan=plan, properties=properties, kind=kind, managed_by=managed_by, sku=sku, identity=identity, **kwargs) self.created_time = None self.changed_time = None @@ -1327,12 +1601,12 @@ def __init__( class GenericResourceFilter(msrest.serialization.Model): """Resource filter. - :param resource_type: The resource type. - :type resource_type: str - :param tagname: The tag name. - :type tagname: str - :param tagvalue: The tag value. - :type tagvalue: str + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar tagname: The tag name. + :vartype tagname: str + :ivar tagvalue: The tag value. + :vartype tagvalue: str """ _attribute_map = { @@ -1349,6 +1623,14 @@ def __init__( tagvalue: Optional[str] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword tagname: The tag name. + :paramtype tagname: str + :keyword tagvalue: The tag value. + :paramtype tagvalue: str + """ super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname @@ -1358,8 +1640,8 @@ def __init__( class HttpMessage(msrest.serialization.Model): """HTTP message. - :param content: HTTP message content. - :type content: any + :ivar content: HTTP message content. + :vartype content: any """ _attribute_map = { @@ -1372,6 +1654,10 @@ def __init__( content: Optional[Any] = None, **kwargs ): + """ + :keyword content: HTTP message content. + :paramtype content: any + """ super(HttpMessage, self).__init__(**kwargs) self.content = content @@ -1385,13 +1671,13 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + :ivar type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the resource. The + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.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}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.resource.resources.v2021_04_01.models.IdentityUserAssignedIdentitiesValue] """ @@ -1414,6 +1700,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "IdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.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.resource.resources.v2021_04_01.models.IdentityUserAssignedIdentitiesValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1446,6 +1742,8 @@ def __init__( self, **kwargs ): + """ + """ super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1454,11 +1752,11 @@ def __init__( class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _attribute_map = { @@ -1473,6 +1771,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name @@ -1485,11 +1790,11 @@ class OnErrorDeploymentExtended(msrest.serialization.Model): :ivar provisioning_state: The state of the provisioning for the on error deployment. :vartype provisioning_state: str - :param type: The deployment on error behavior type. Possible values are LastSuccessful and + :ivar type: The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". - :type type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType - :param deployment_name: The deployment to be used on error case. - :type deployment_name: str + :vartype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :ivar deployment_name: The deployment to be used on error case. + :vartype deployment_name: str """ _validation = { @@ -1509,6 +1814,13 @@ def __init__( deployment_name: Optional[str] = None, **kwargs ): + """ + :keyword type: The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. Possible values include: "LastSuccessful", "SpecificDeployment". + :paramtype type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.OnErrorDeploymentType + :keyword deployment_name: The deployment to be used on error case. + :paramtype deployment_name: str + """ super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type @@ -1518,10 +1830,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay """ _attribute_map = { @@ -1536,6 +1848,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.resources.v2021_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1544,14 +1862,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1570,6 +1888,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1580,10 +1908,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1598,6 +1926,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1608,10 +1942,10 @@ class ParametersLink(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param uri: Required. The URI of the parameters file. - :type uri: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str + :ivar uri: Required. The URI of the parameters file. + :vartype uri: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str """ _validation = { @@ -1630,6 +1964,12 @@ def __init__( content_version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Required. The URI of the parameters file. + :paramtype uri: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + """ super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version @@ -1638,14 +1978,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -1664,6 +2004,16 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -1674,16 +2024,16 @@ def __init__( class Plan(msrest.serialization.Model): """Plan for the resource. - :param name: The plan ID. - :type name: str - :param publisher: The publisher ID. - :type publisher: str - :param product: The offer ID. - :type product: str - :param promotion_code: The promotion code. - :type promotion_code: str - :param version: The plan's version. - :type version: str + :ivar name: The plan ID. + :vartype name: str + :ivar publisher: The publisher ID. + :vartype publisher: str + :ivar product: The offer ID. + :vartype product: str + :ivar promotion_code: The promotion code. + :vartype promotion_code: str + :ivar version: The plan's version. + :vartype version: str """ _attribute_map = { @@ -1704,6 +2054,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: The plan ID. + :paramtype name: str + :keyword publisher: The publisher ID. + :paramtype publisher: str + :keyword product: The offer ID. + :paramtype product: str + :keyword promotion_code: The promotion code. + :paramtype promotion_code: str + :keyword version: The plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1719,8 +2081,8 @@ class Provider(msrest.serialization.Model): :ivar id: The provider ID. :vartype id: str - :param namespace: The namespace of the resource provider. - :type namespace: str + :ivar namespace: The namespace of the resource provider. + :vartype namespace: str :ivar registration_state: The registration state of the resource provider. :vartype registration_state: str :ivar registration_policy: The registration policy of the resource provider. @@ -1728,9 +2090,9 @@ class Provider(msrest.serialization.Model): :ivar resource_types: The collection of provider resource types. :vartype resource_types: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] - :param provider_authorization_consent_state: The provider authorization consent state. Possible + :ivar provider_authorization_consent_state: The provider authorization consent state. Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". - :type provider_authorization_consent_state: str or + :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ @@ -1757,6 +2119,14 @@ def __init__( provider_authorization_consent_state: Optional[Union[str, "ProviderAuthorizationConsentState"]] = None, **kwargs ): + """ + :keyword namespace: The namespace of the resource provider. + :paramtype namespace: str + :keyword provider_authorization_consent_state: The provider authorization consent state. + Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :paramtype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState + """ super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1769,8 +2139,8 @@ def __init__( class ProviderConsentDefinition(msrest.serialization.Model): """The provider consent. - :param consent_to_authorization: A value indicating whether authorization is consented or not. - :type consent_to_authorization: bool + :ivar consent_to_authorization: A value indicating whether authorization is consented or not. + :vartype consent_to_authorization: bool """ _attribute_map = { @@ -1783,6 +2153,11 @@ def __init__( consent_to_authorization: Optional[bool] = None, **kwargs ): + """ + :keyword consent_to_authorization: A value indicating whether authorization is consented or + not. + :paramtype consent_to_authorization: bool + """ super(ProviderConsentDefinition, self).__init__(**kwargs) self.consent_to_authorization = consent_to_authorization @@ -1790,12 +2165,12 @@ def __init__( class ProviderExtendedLocation(msrest.serialization.Model): """The provider extended location. - :param location: The azure location. - :type location: str - :param type: The extended location type. - :type type: str - :param extended_locations: The extended locations for the azure location. - :type extended_locations: list[str] + :ivar location: The azure location. + :vartype location: str + :ivar type: The extended location type. + :vartype type: str + :ivar extended_locations: The extended locations for the azure location. + :vartype extended_locations: list[str] """ _attribute_map = { @@ -1812,6 +2187,14 @@ def __init__( extended_locations: Optional[List[str]] = None, **kwargs ): + """ + :keyword location: The azure location. + :paramtype location: str + :keyword type: The extended location type. + :paramtype type: str + :keyword extended_locations: The extended locations for the azure location. + :paramtype extended_locations: list[str] + """ super(ProviderExtendedLocation, self).__init__(**kwargs) self.location = location self.type = type @@ -1823,8 +2206,8 @@ class ProviderListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource providers. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + :ivar value: An array of resource providers. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1844,6 +2227,10 @@ def __init__( value: Optional[List["Provider"]] = None, **kwargs ): + """ + :keyword value: An array of resource providers. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.Provider] + """ super(ProviderListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1852,16 +2239,16 @@ def __init__( class ProviderPermission(msrest.serialization.Model): """The provider permission. - :param application_id: The application id. - :type application_id: str - :param role_definition: Role definition properties. - :type role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :param managed_by_role_definition: Role definition properties. - :type managed_by_role_definition: + :ivar application_id: The application id. + :vartype application_id: str + :ivar role_definition: Role definition properties. + :vartype role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :ivar managed_by_role_definition: Role definition properties. + :vartype managed_by_role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition - :param provider_authorization_consent_state: The provider authorization consent state. Possible + :ivar provider_authorization_consent_state: The provider authorization consent state. Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". - :type provider_authorization_consent_state: str or + :vartype provider_authorization_consent_state: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState """ @@ -1881,6 +2268,19 @@ def __init__( provider_authorization_consent_state: Optional[Union[str, "ProviderAuthorizationConsentState"]] = None, **kwargs ): + """ + :keyword application_id: The application id. + :paramtype application_id: str + :keyword role_definition: Role definition properties. + :paramtype role_definition: ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :keyword managed_by_role_definition: Role definition properties. + :paramtype managed_by_role_definition: + ~azure.mgmt.resource.resources.v2021_04_01.models.RoleDefinition + :keyword provider_authorization_consent_state: The provider authorization consent state. + Possible values include: "NotSpecified", "Required", "NotRequired", "Consented". + :paramtype provider_authorization_consent_state: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderAuthorizationConsentState + """ super(ProviderPermission, self).__init__(**kwargs) self.application_id = application_id self.role_definition = role_definition @@ -1893,8 +2293,8 @@ class ProviderPermissionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of provider permissions. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] + :ivar value: An array of provider permissions. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1914,6 +2314,10 @@ def __init__( value: Optional[List["ProviderPermission"]] = None, **kwargs ): + """ + :keyword value: An array of provider permissions. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderPermission] + """ super(ProviderPermissionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1922,8 +2326,8 @@ def __init__( class ProviderRegistrationRequest(msrest.serialization.Model): """The provider registration definition. - :param third_party_provider_consent: The provider consent. - :type third_party_provider_consent: + :ivar third_party_provider_consent: The provider consent. + :vartype third_party_provider_consent: ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderConsentDefinition """ @@ -1937,6 +2341,11 @@ def __init__( third_party_provider_consent: Optional["ProviderConsentDefinition"] = None, **kwargs ): + """ + :keyword third_party_provider_consent: The provider consent. + :paramtype third_party_provider_consent: + ~azure.mgmt.resource.resources.v2021_04_01.models.ProviderConsentDefinition + """ super(ProviderRegistrationRequest, self).__init__(**kwargs) self.third_party_provider_consent = third_party_provider_consent @@ -1946,25 +2355,27 @@ class ProviderResourceType(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_type: The resource type. - :type resource_type: str - :param locations: The collection of locations where this resource type can be created. - :type locations: list[str] - :param location_mappings: The location mappings that are supported by this resource type. - :type location_mappings: + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar locations: The collection of locations where this resource type can be created. + :vartype locations: list[str] + :ivar location_mappings: The location mappings that are supported by this resource type. + :vartype location_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderExtendedLocation] - :param aliases: The aliases that are supported by this resource type. - :type aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] - :param api_versions: The API version. - :type api_versions: list[str] + :ivar aliases: The aliases that are supported by this resource type. + :vartype aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] + :ivar api_versions: The API version. + :vartype api_versions: list[str] :ivar default_api_version: The default API version. :vartype default_api_version: str + :ivar zone_mappings: + :vartype zone_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ZoneMapping] :ivar api_profiles: The API profiles for the resource provider. :vartype api_profiles: list[~azure.mgmt.resource.resources.v2021_04_01.models.ApiProfile] - :param capabilities: The additional capabilities offered by this resource type. - :type capabilities: str - :param properties: The properties. - :type properties: dict[str, str] + :ivar capabilities: The additional capabilities offered by this resource type. + :vartype capabilities: str + :ivar properties: The properties. + :vartype properties: dict[str, str] """ _validation = { @@ -1979,6 +2390,7 @@ class ProviderResourceType(msrest.serialization.Model): 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'default_api_version': {'key': 'defaultApiVersion', 'type': 'str'}, + 'zone_mappings': {'key': 'zoneMappings', 'type': '[ZoneMapping]'}, 'api_profiles': {'key': 'apiProfiles', 'type': '[ApiProfile]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, @@ -1992,10 +2404,30 @@ def __init__( location_mappings: Optional[List["ProviderExtendedLocation"]] = None, aliases: Optional[List["Alias"]] = None, api_versions: Optional[List[str]] = None, + zone_mappings: Optional[List["ZoneMapping"]] = None, capabilities: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword resource_type: The resource type. + :paramtype resource_type: str + :keyword locations: The collection of locations where this resource type can be created. + :paramtype locations: list[str] + :keyword location_mappings: The location mappings that are supported by this resource type. + :paramtype location_mappings: + list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderExtendedLocation] + :keyword aliases: The aliases that are supported by this resource type. + :paramtype aliases: list[~azure.mgmt.resource.resources.v2021_04_01.models.Alias] + :keyword api_versions: The API version. + :paramtype api_versions: list[str] + :keyword zone_mappings: + :paramtype zone_mappings: list[~azure.mgmt.resource.resources.v2021_04_01.models.ZoneMapping] + :keyword capabilities: The additional capabilities offered by this resource type. + :paramtype capabilities: str + :keyword properties: The properties. + :paramtype properties: dict[str, str] + """ super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -2003,6 +2435,7 @@ def __init__( self.aliases = aliases self.api_versions = api_versions self.default_api_version = None + self.zone_mappings = zone_mappings self.api_profiles = None self.capabilities = capabilities self.properties = properties @@ -2013,8 +2446,8 @@ class ProviderResourceTypeListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource types. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] + :ivar value: An array of resource types. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2034,6 +2467,10 @@ def __init__( value: Optional[List["ProviderResourceType"]] = None, **kwargs ): + """ + :keyword value: An array of resource types. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderResourceType] + """ super(ProviderResourceTypeListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2052,15 +2489,15 @@ class ResourceGroup(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :param location: Required. The location of the resource group. It cannot be changed after the + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :ivar location: Required. The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. - :type location: str - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :vartype location: str + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _validation = { @@ -2089,6 +2526,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :keyword location: Required. The location of the resource group. It cannot be changed after the + resource group has been created. It must be one of the supported Azure locations. + :paramtype location: str + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -2102,10 +2551,10 @@ def __init__( class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. - :param template: The template content. - :type template: any - :param error: The template export error. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar template: The template content. + :vartype template: any + :ivar error: The template export error. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ _attribute_map = { @@ -2120,6 +2569,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword template: The template content. + :paramtype template: any + :keyword error: The template export error. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + """ super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error @@ -2128,10 +2583,10 @@ def __init__( class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. - :param tag_name: The tag name. - :type tag_name: str - :param tag_value: The tag value. - :type tag_value: str + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar tag_value: The tag value. + :vartype tag_value: str """ _attribute_map = { @@ -2146,6 +2601,12 @@ def __init__( tag_value: Optional[str] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword tag_value: The tag value. + :paramtype tag_value: str + """ super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value @@ -2156,8 +2617,8 @@ class ResourceGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resource groups. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + :ivar value: An array of resource groups. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2177,6 +2638,10 @@ def __init__( value: Optional[List["ResourceGroup"]] = None, **kwargs ): + """ + :keyword value: An array of resource groups. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroup] + """ super(ResourceGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2185,14 +2650,14 @@ def __init__( class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. - :param name: The name of the resource group. - :type name: str - :param properties: The resource group properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties - :param managed_by: The ID of the resource that manages this resource group. - :type managed_by: str - :param tags: A set of tags. The tags attached to the resource group. - :type tags: dict[str, str] + :ivar name: The name of the resource group. + :vartype name: str + :ivar properties: The resource group properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :ivar managed_by: The ID of the resource that manages this resource group. + :vartype managed_by: str + :ivar tags: A set of tags. The tags attached to the resource group. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2211,6 +2676,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: The name of the resource group. + :paramtype name: str + :keyword properties: The resource group properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupProperties + :keyword managed_by: The ID of the resource that manages this resource group. + :paramtype managed_by: str + :keyword tags: A set of tags. The tags attached to the resource group. + :paramtype tags: dict[str, str] + """ super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -2239,6 +2715,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None @@ -2248,8 +2726,8 @@ class ResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of resources. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + :ivar value: An array of resources. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2269,6 +2747,11 @@ def __init__( value: Optional[List["GenericResourceExpanded"]] = None, **kwargs ): + """ + :keyword value: An array of resources. + :paramtype value: + list[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResourceExpanded] + """ super(ResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2277,16 +2760,16 @@ def __init__( class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. - :param publisher: Operation description. - :type publisher: str - :param provider: Operation provider. - :type provider: str - :param resource: Operation resource. - :type resource: str - :param operation: Resource provider operation. - :type operation: str - :param description: Operation description. - :type description: str + :ivar publisher: Operation description. + :vartype publisher: str + :ivar provider: Operation provider. + :vartype provider: str + :ivar resource: Operation resource. + :vartype resource: str + :ivar operation: Resource provider operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str """ _attribute_map = { @@ -2307,6 +2790,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: Operation description. + :paramtype publisher: str + :keyword provider: Operation provider. + :paramtype provider: str + :keyword resource: Operation resource. + :paramtype resource: str + :keyword operation: Resource provider operation. + :paramtype operation: str + :keyword description: Operation description. + :paramtype description: str + """ super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -2336,6 +2831,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceReference, self).__init__(**kwargs) self.id = None @@ -2343,10 +2840,10 @@ def __init__( class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. - :param resources: The IDs of the resources. - :type resources: list[str] - :param target_resource_group: The target resource group. - :type target_resource_group: str + :ivar resources: The IDs of the resources. + :vartype resources: list[str] + :ivar target_resource_group: The target resource group. + :vartype target_resource_group: str """ _attribute_map = { @@ -2361,6 +2858,12 @@ def __init__( target_resource_group: Optional[str] = None, **kwargs ): + """ + :keyword resources: The IDs of the resources. + :paramtype resources: list[str] + :keyword target_resource_group: The target resource group. + :paramtype target_resource_group: str + """ super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group @@ -2369,16 +2872,16 @@ def __init__( class RoleDefinition(msrest.serialization.Model): """Role definition properties. - :param id: The role definition ID. - :type id: str - :param name: The role definition name. - :type name: str - :param is_service_role: If this is a service role. - :type is_service_role: bool - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] - :param scopes: Role definition assignable scopes. - :type scopes: list[str] + :ivar id: The role definition ID. + :vartype id: str + :ivar name: The role definition name. + :vartype name: str + :ivar is_service_role: If this is a service role. + :vartype is_service_role: bool + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] + :ivar scopes: Role definition assignable scopes. + :vartype scopes: list[str] """ _attribute_map = { @@ -2399,6 +2902,18 @@ def __init__( scopes: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: The role definition ID. + :paramtype id: str + :keyword name: The role definition name. + :paramtype name: str + :keyword is_service_role: If this is a service role. + :paramtype is_service_role: bool + :keyword permissions: Role definition permissions. + :paramtype permissions: list[~azure.mgmt.resource.resources.v2021_04_01.models.Permission] + :keyword scopes: Role definition assignable scopes. + :paramtype scopes: list[str] + """ super(RoleDefinition, self).__init__(**kwargs) self.id = id self.name = name @@ -2412,12 +2927,12 @@ class ScopedDeployment(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties - :param tags: A set of tags. Deployment tags. - :type tags: dict[str, str] + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :ivar tags: A set of tags. Deployment tags. + :vartype tags: dict[str, str] """ _validation = { @@ -2439,6 +2954,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentProperties + :keyword tags: A set of tags. Deployment tags. + :paramtype tags: dict[str, str] + """ super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2450,10 +2973,11 @@ class ScopedDeploymentWhatIf(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location to store the deployment data. - :type location: str - :param properties: Required. The deployment properties. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + :ivar location: Required. The location to store the deployment data. + :vartype location: str + :ivar properties: Required. The deployment properties. + :vartype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties """ _validation = { @@ -2473,6 +2997,13 @@ def __init__( properties: "DeploymentWhatIfProperties", **kwargs ): + """ + :keyword location: Required. The location to store the deployment data. + :paramtype location: str + :keyword properties: Required. The deployment properties. + :paramtype properties: + ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIfProperties + """ super(ScopedDeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -2481,18 +3012,18 @@ def __init__( class Sku(msrest.serialization.Model): """SKU for the resource. - :param name: The SKU name. - :type name: str - :param tier: The SKU tier. - :type tier: str - :param size: The SKU size. - :type size: str - :param family: The SKU family. - :type family: str - :param model: The SKU model. - :type model: str - :param capacity: The SKU capacity. - :type capacity: int + :ivar name: The SKU name. + :vartype name: str + :ivar tier: The SKU tier. + :vartype tier: str + :ivar size: The SKU size. + :vartype size: str + :ivar family: The SKU family. + :vartype family: str + :ivar model: The SKU model. + :vartype model: str + :ivar capacity: The SKU capacity. + :vartype capacity: int """ _attribute_map = { @@ -2515,6 +3046,20 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: The SKU name. + :paramtype name: str + :keyword tier: The SKU tier. + :paramtype tier: str + :keyword size: The SKU size. + :paramtype size: str + :keyword family: The SKU family. + :paramtype family: str + :keyword model: The SKU model. + :paramtype model: str + :keyword capacity: The SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2527,10 +3072,10 @@ def __init__( class StatusMessage(msrest.serialization.Model): """Operation status message object. - :param status: Status of the deployment operation. - :type status: str - :param error: The error reported by the operation. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar status: Status of the deployment operation. + :vartype status: str + :ivar error: The error reported by the operation. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse """ _attribute_map = { @@ -2545,6 +3090,12 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword status: Status of the deployment operation. + :paramtype status: str + :keyword error: The error reported by the operation. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + """ super(StatusMessage, self).__init__(**kwargs) self.status = status self.error = error @@ -2553,8 +3104,8 @@ def __init__( class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID. - :type id: str + :ivar id: Resource ID. + :vartype id: str """ _attribute_map = { @@ -2567,6 +3118,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource ID. + :paramtype id: str + """ super(SubResource, self).__init__(**kwargs) self.id = id @@ -2574,10 +3129,10 @@ def __init__( class TagCount(msrest.serialization.Model): """Tag count. - :param type: Type of count. - :type type: str - :param value: Value of count. - :type value: int + :ivar type: Type of count. + :vartype type: str + :ivar value: Value of count. + :vartype value: int """ _attribute_map = { @@ -2592,6 +3147,12 @@ def __init__( value: Optional[int] = None, **kwargs ): + """ + :keyword type: Type of count. + :paramtype type: str + :keyword value: Value of count. + :paramtype value: int + """ super(TagCount, self).__init__(**kwargs) self.type = type self.value = value @@ -2604,13 +3165,13 @@ class TagDetails(msrest.serialization.Model): :ivar id: The tag name ID. :vartype id: str - :param tag_name: The tag name. - :type tag_name: str - :param count: The total number of resources that use the resource tag. When a tag is initially + :ivar tag_name: The tag name. + :vartype tag_name: str + :ivar count: The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0. - :type count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount - :param values: The list of tag values. - :type values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] + :vartype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :ivar values: The list of tag values. + :vartype values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] """ _validation = { @@ -2632,6 +3193,15 @@ def __init__( values: Optional[List["TagValue"]] = None, **kwargs ): + """ + :keyword tag_name: The tag name. + :paramtype tag_name: str + :keyword count: The total number of resources that use the resource tag. When a tag is + initially created and has no associated resources, the value is 0. + :paramtype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :keyword values: The list of tag values. + :paramtype values: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagValue] + """ super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -2642,8 +3212,8 @@ def __init__( class Tags(msrest.serialization.Model): """A dictionary of name and value pairs. - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2656,6 +3226,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags @@ -2665,8 +3239,8 @@ class TagsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of tags. - :type value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + :ivar value: An array of tags. + :vartype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -2686,6 +3260,10 @@ def __init__( value: Optional[List["TagDetails"]] = None, **kwargs ): + """ + :keyword value: An array of tags. + :paramtype value: list[~azure.mgmt.resource.resources.v2021_04_01.models.TagDetails] + """ super(TagsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2694,11 +3272,11 @@ def __init__( class TagsPatchResource(msrest.serialization.Model): """Wrapper resource for tags patch API request only. - :param operation: The operation type for the patch API. Possible values include: "Replace", + :ivar operation: The operation type for the patch API. Possible values include: "Replace", "Merge", "Delete". - :type operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation - :param properties: The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + :vartype operation: str or ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation + :ivar properties: The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _attribute_map = { @@ -2713,6 +3291,14 @@ def __init__( properties: Optional["Tags"] = None, **kwargs ): + """ + :keyword operation: The operation type for the patch API. Possible values include: "Replace", + "Merge", "Delete". + :paramtype operation: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.TagsPatchOperation + :keyword properties: The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + """ super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties @@ -2731,8 +3317,8 @@ class TagsResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the tags wrapper resource. :vartype type: str - :param properties: Required. The set of tags. - :type properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + :ivar properties: Required. The set of tags. + :vartype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags """ _validation = { @@ -2755,6 +3341,10 @@ def __init__( properties: "Tags", **kwargs ): + """ + :keyword properties: Required. The set of tags. + :paramtype properties: ~azure.mgmt.resource.resources.v2021_04_01.models.Tags + """ super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -2769,10 +3359,10 @@ class TagValue(msrest.serialization.Model): :ivar id: The tag value ID. :vartype id: str - :param tag_value: The tag value. - :type tag_value: str - :param count: The tag value count. - :type count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + :ivar tag_value: The tag value. + :vartype tag_value: str + :ivar count: The tag value count. + :vartype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount """ _validation = { @@ -2792,6 +3382,12 @@ def __init__( count: Optional["TagCount"] = None, **kwargs ): + """ + :keyword tag_value: The tag value. + :paramtype tag_value: str + :keyword count: The tag value count. + :paramtype count: ~azure.mgmt.resource.resources.v2021_04_01.models.TagCount + """ super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value @@ -2801,12 +3397,12 @@ def __init__( class TargetResource(msrest.serialization.Model): """Target resource. - :param id: The ID of the resource. - :type id: str - :param resource_name: The name of the resource. - :type resource_name: str - :param resource_type: The type of the resource. - :type resource_type: str + :ivar id: The ID of the resource. + :vartype id: str + :ivar resource_name: The name of the resource. + :vartype resource_name: str + :ivar resource_type: The type of the resource. + :vartype resource_type: str """ _attribute_map = { @@ -2823,6 +3419,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the resource. + :paramtype id: str + :keyword resource_name: The name of the resource. + :paramtype resource_name: str + :keyword resource_type: The type of the resource. + :paramtype resource_type: str + """ super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name @@ -2832,10 +3436,10 @@ def __init__( class TemplateHashResult(msrest.serialization.Model): """Result of the request to calculate template hash. It contains a string of minified template and its hash. - :param minified_template: The minified template string. - :type minified_template: str - :param template_hash: The template hash. - :type template_hash: str + :ivar minified_template: The minified template string. + :vartype minified_template: str + :ivar template_hash: The template hash. + :vartype template_hash: str """ _attribute_map = { @@ -2850,6 +3454,12 @@ def __init__( template_hash: Optional[str] = None, **kwargs ): + """ + :keyword minified_template: The minified template string. + :paramtype minified_template: str + :keyword template_hash: The template hash. + :paramtype template_hash: str + """ super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash @@ -2858,20 +3468,20 @@ def __init__( class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. - :param uri: The URI of the template to deploy. Use either the uri or id property, but not both. - :type uri: str - :param id: The resource id of a Template Spec. Use either the id or uri property, but not both. - :type id: str - :param relative_path: The relativePath property can be used to deploy a linked template at a + :ivar uri: The URI of the template to deploy. Use either the uri or id property, but not both. + :vartype uri: str + :ivar id: The resource id of a Template Spec. Use either the id or uri property, but not both. + :vartype id: str + :ivar relative_path: The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template was linked with a TemplateSpec, this will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath URIs. - :type relative_path: str - :param content_version: If included, must match the ContentVersion in the template. - :type content_version: str - :param query_string: The query string (for example, a SAS token) to be used with the + :vartype relative_path: str + :ivar content_version: If included, must match the ContentVersion in the template. + :vartype content_version: str + :ivar query_string: The query string (for example, a SAS token) to be used with the templateLink URI. - :type query_string: str + :vartype query_string: str """ _attribute_map = { @@ -2892,6 +3502,24 @@ def __init__( query_string: Optional[str] = None, **kwargs ): + """ + :keyword uri: The URI of the template to deploy. Use either the uri or id property, but not + both. + :paramtype uri: str + :keyword id: The resource id of a Template Spec. Use either the id or uri property, but not + both. + :paramtype id: str + :keyword relative_path: The relativePath property can be used to deploy a linked template at a + location relative to the parent. If the parent template was linked with a TemplateSpec, this + will reference an artifact in the TemplateSpec. If the parent was linked with a URI, the child + deployment will be a combination of the parent and relativePath URIs. + :paramtype relative_path: str + :keyword content_version: If included, must match the ContentVersion in the template. + :paramtype content_version: str + :keyword query_string: The query string (for example, a SAS token) to be used with the + templateLink URI. + :paramtype query_string: str + """ super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.id = id @@ -2905,20 +3533,20 @@ class WhatIfChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID. - :type resource_id: str - :param change_type: Required. Type of change that will be made to the resource when the + :ivar resource_id: Required. Resource ID. + :vartype resource_id: str + :ivar change_type: Required. Type of change that will be made to the resource when the deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", "NoChange", "Modify", "Unsupported". - :type change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType - :param unsupported_reason: The explanation about why the resource is unsupported by What-If. - :type unsupported_reason: str - :param before: The snapshot of the resource before the deployment is executed. - :type before: any - :param after: The predicted snapshot of the resource after the deployment is executed. - :type after: any - :param delta: The predicted changes to resource properties. - :type delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + :vartype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType + :ivar unsupported_reason: The explanation about why the resource is unsupported by What-If. + :vartype unsupported_reason: str + :ivar before: The snapshot of the resource before the deployment is executed. + :vartype before: any + :ivar after: The predicted snapshot of the resource after the deployment is executed. + :vartype after: any + :ivar delta: The predicted changes to resource properties. + :vartype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { @@ -2946,6 +3574,22 @@ def __init__( delta: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: Required. Resource ID. + :paramtype resource_id: str + :keyword change_type: Required. Type of change that will be made to the resource when the + deployment is executed. Possible values include: "Create", "Delete", "Ignore", "Deploy", + "NoChange", "Modify", "Unsupported". + :paramtype change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.ChangeType + :keyword unsupported_reason: The explanation about why the resource is unsupported by What-If. + :paramtype unsupported_reason: str + :keyword before: The snapshot of the resource before the deployment is executed. + :paramtype before: any + :keyword after: The predicted snapshot of the resource after the deployment is executed. + :paramtype after: any + :keyword delta: The predicted changes to resource properties. + :paramtype delta: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + """ super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -2958,12 +3602,12 @@ def __init__( class WhatIfOperationResult(msrest.serialization.Model): """Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - :param status: Status of the What-If operation. - :type status: str - :param error: Error when What-If operation fails. - :type error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse - :param changes: List of resource changes predicted by What-If operation. - :type changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] + :ivar status: Status of the What-If operation. + :vartype status: str + :ivar error: Error when What-If operation fails. + :vartype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :ivar changes: List of resource changes predicted by What-If operation. + :vartype changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] """ _attribute_map = { @@ -2980,6 +3624,14 @@ def __init__( changes: Optional[List["WhatIfChange"]] = None, **kwargs ): + """ + :keyword status: Status of the What-If operation. + :paramtype status: str + :keyword error: Error when What-If operation fails. + :paramtype error: ~azure.mgmt.resource.resources.v2021_04_01.models.ErrorResponse + :keyword changes: List of resource changes predicted by What-If operation. + :paramtype changes: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfChange] + """ super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -2991,18 +3643,18 @@ class WhatIfPropertyChange(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. The path of the property. - :type path: str - :param property_change_type: Required. The type of property change. Possible values include: + :ivar path: Required. The path of the property. + :vartype path: str + :ivar property_change_type: Required. The type of property change. Possible values include: "Create", "Delete", "Modify", "Array", "NoEffect". - :type property_change_type: str or + :vartype property_change_type: str or ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType - :param before: The value of the property before the deployment is executed. - :type before: any - :param after: The value of the property after the deployment is executed. - :type after: any - :param children: Nested property changes. - :type children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + :ivar before: The value of the property before the deployment is executed. + :vartype before: any + :ivar after: The value of the property after the deployment is executed. + :vartype after: any + :ivar children: Nested property changes. + :vartype children: list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] """ _validation = { @@ -3028,9 +3680,56 @@ def __init__( children: Optional[List["WhatIfPropertyChange"]] = None, **kwargs ): + """ + :keyword path: Required. The path of the property. + :paramtype path: str + :keyword property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array", "NoEffect". + :paramtype property_change_type: str or + ~azure.mgmt.resource.resources.v2021_04_01.models.PropertyChangeType + :keyword before: The value of the property before the deployment is executed. + :paramtype before: any + :keyword after: The value of the property after the deployment is executed. + :paramtype after: any + :keyword children: Nested property changes. + :paramtype children: + list[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfPropertyChange] + """ super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type self.before = before self.after = after self.children = children + + +class ZoneMapping(msrest.serialization.Model): + """ZoneMapping. + + :ivar location: The location of the zone mapping. + :vartype location: str + :ivar zones: + :vartype zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + zones: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword location: The location of the zone mapping. + :paramtype location: str + :keyword zones: + :paramtype zones: list[str] + """ + super(ZoneMapping, self).__init__(**kwargs) + self.location = location + self.zones = zones diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py index 8d5aed7679b8f..c04261605d14e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/models/_resource_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathAttributes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The attributes of the token that the alias path is referring to. """ @@ -35,7 +20,7 @@ class AliasPathAttributes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token that the alias path is referring to is modifiable by policies with 'modify' effect. MODIFIABLE = "Modifiable" -class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPathTokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the token that the alias path is referring to. """ @@ -56,7 +41,7 @@ class AliasPathTokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The token type is boolean. BOOLEAN = "Boolean" -class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasPatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of alias pattern """ @@ -65,7 +50,7 @@ class AliasPatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Extract is the only allowed value. EXTRACT = "Extract" -class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AliasType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the alias. """ @@ -76,7 +61,7 @@ class AliasType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Alias value is secret. MASK = "Mask" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of change that will be made to the resource when the deployment is executed. """ @@ -101,7 +86,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The resource is not supported by What-If. UNSUPPORTED = "Unsupported" -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, resources are deployed without deleting existing resources that are not included in the template. In Complete mode, resources are deployed and existing resources in @@ -112,7 +97,7 @@ class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREMENTAL = "Incremental" COMPLETE = "Complete" -class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExpressionEvaluationOptionsScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scope to be used for evaluation of parameters, variables and functions in a nested template. """ @@ -121,13 +106,13 @@ class ExpressionEvaluationOptionsScopeType(with_metaclass(_CaseInsensitiveEnumMe OUTER = "Outer" INNER = "Inner" -class ExtendedLocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The extended location type. """ EDGE_ZONE = "EdgeZone" -class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnErrorDeploymentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. """ @@ -135,7 +120,7 @@ class OnErrorDeploymentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) LAST_SUCCESSFUL = "LastSuccessful" SPECIFIC_DEPLOYMENT = "SpecificDeployment" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PropertyChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of property change. """ @@ -153,7 +138,7 @@ class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The property will not be set or updated. NO_EFFECT = "NoEffect" -class ProviderAuthorizationConsentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProviderAuthorizationConsentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provider authorization consent state. """ @@ -162,7 +147,7 @@ class ProviderAuthorizationConsentState(with_metaclass(_CaseInsensitiveEnumMeta, NOT_REQUIRED = "NotRequired" CONSENTED = "Consented" -class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the current provisioning operation. """ @@ -188,7 +173,7 @@ class ProvisioningOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) #: deployment. DEPLOYMENT_CLEANUP = "DeploymentCleanup" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Denotes the state of provisioning. """ @@ -205,7 +190,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" UPDATING = "Updating" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ @@ -214,7 +199,7 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagsPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operation type for the patch API. """ @@ -226,7 +211,7 @@ class TagsPatchOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The 'delete' option allows selectively deleting tags based on given names or name/value pairs. DELETE = "Delete" -class WhatIfResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WhatIfResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the What-If results """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployment_operations_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployment_operations_operations.py index fcbedf003da84..e5cc2b7062f99 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployment_operations_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployment_operations_operations.py @@ -5,24 +5,402 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request( + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request( + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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, # type: str + deployment_name, # type: str + operation_id, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "operationId": _SERIALIZER.url("operation_id", operation_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_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class DeploymentOperationsOperations(object): """DeploymentOperationsOperations operations. @@ -45,6 +423,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_at_scope( self, scope, # type: str @@ -71,27 +450,17 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,8 +474,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -124,8 +496,10 @@ def list_at_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -133,37 +507,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -181,11 +551,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -209,26 +581,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -242,8 +604,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, deployment_name, # type: str @@ -258,8 +623,10 @@ def list_at_tenant_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -267,36 +634,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -314,11 +676,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -345,27 +709,17 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + operation_id=operation_id, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -379,8 +733,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -398,8 +755,10 @@ def list_at_management_group_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -407,37 +766,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -455,11 +810,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -483,27 +840,17 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -517,8 +864,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, deployment_name, # type: str @@ -533,8 +883,10 @@ def list_at_subscription_scope( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -542,37 +894,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -590,11 +938,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -621,28 +971,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -656,8 +996,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -675,8 +1018,10 @@ def list( :param top: The number of results to return. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] + :return: An iterator like instance of either DeploymentOperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentOperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentOperationsListResult"] @@ -684,38 +1029,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + top=top, + 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('DeploymentOperationsListResult', pipeline_response) + deserialized = self._deserialize("DeploymentOperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -733,6 +1075,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployments_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployments_operations.py index 36fda6cde6f3e..2225e94eb2d8c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployments_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_deployments_operations.py @@ -5,26 +5,1637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_scope_request_initial( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_scope_request( + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_tenant_scope_request_initial( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_tenant_scope_request( + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/deployments/') + + # 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_check_existence_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_cancel_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_validate_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_what_if_at_management_group_scope_request_initial( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_export_template_at_management_group_scope_request( + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_management_group_scope_request( + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/') + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + 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 top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_at_subscription_scope_request_initial( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_at_subscription_scope_request( + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_at_subscription_scope_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_existence_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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_cancel_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_validate_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_what_if_request_initial( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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] + 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, + **kwargs + ) + + +def build_export_template_request( + resource_group_name, # type: str + deployment_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, 'str', max_length=64, 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_calculate_template_hash_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/calculateTemplateHash') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class DeploymentsOperations(object): """DeploymentsOperations operations. @@ -59,26 +1670,16 @@ def _delete_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + template_url=self._delete_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -91,6 +1692,8 @@ def _delete_at_scope_initial( _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_scope( self, scope, # type: str @@ -114,15 +1717,17 @@ def begin_delete_at_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -136,20 +1741,14 @@ def begin_delete_at_scope( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -161,8 +1760,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_scope( self, scope, # type: str @@ -186,26 +1787,16 @@ def check_existence_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.check_existence_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -215,10 +1806,11 @@ def check_existence_at_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_scope_initial( self, scope, # type: str @@ -232,31 +1824,21 @@ def _create_or_update_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +1856,11 @@ def _create_or_update_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_scope( self, scope, # type: str @@ -296,15 +1881,20 @@ def begin_create_or_update_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -316,26 +1906,21 @@ def begin_create_or_update_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -347,8 +1932,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_scope( self, scope, # type: str @@ -372,26 +1959,16 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -405,8 +1982,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_scope( self, scope, # type: str @@ -435,26 +2015,16 @@ def cancel_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.cancel_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -467,6 +2037,7 @@ def cancel_at_scope( cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_scope_initial( self, scope, # type: str @@ -480,31 +2051,21 @@ def _validate_at_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_scope_request_initial( + scope=scope, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -523,8 +2084,11 @@ def _validate_at_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_scope( self, scope, # type: str @@ -544,15 +2108,20 @@ def begin_validate_at_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -564,26 +2133,21 @@ def begin_validate_at_scope( scope=scope, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -595,8 +2159,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + @distributed_trace def export_template_at_scope( self, scope, # type: str @@ -620,26 +2186,16 @@ def export_template_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_scope_request( + scope=scope, + deployment_name=deployment_name, + template_url=self.export_template_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -653,8 +2209,11 @@ def export_template_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_scope( self, scope, # type: str @@ -673,8 +2232,10 @@ def list_at_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -682,38 +2243,33 @@ def list_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_scope_request( + scope=scope, + filter=filter, + top=top, + template_url=self.list_at_scope.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_at_scope_request( + scope=scope, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -731,6 +2287,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -747,25 +2304,15 @@ def _delete_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_tenant_scope_request_initial( + deployment_name=deployment_name, + template_url=self._delete_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -778,6 +2325,8 @@ def _delete_at_tenant_scope_initial( _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_tenant_scope( self, deployment_name, # type: str @@ -798,15 +2347,17 @@ def begin_delete_at_tenant_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -819,19 +2370,14 @@ def begin_delete_at_tenant_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -843,8 +2389,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_tenant_scope( self, deployment_name, # type: str @@ -865,25 +2413,15 @@ def check_existence_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.check_existence_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -893,10 +2431,11 @@ def check_existence_at_tenant_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_tenant_scope_initial( self, deployment_name, # type: str @@ -909,30 +2448,20 @@ def _create_or_update_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -950,8 +2479,11 @@ def _create_or_update_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_tenant_scope( self, deployment_name, # type: str @@ -969,15 +2501,20 @@ def begin_create_or_update_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -988,25 +2525,21 @@ def begin_create_or_update_at_tenant_scope( raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1018,8 +2551,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_tenant_scope( self, deployment_name, # type: str @@ -1040,25 +2575,15 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1072,8 +2597,11 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_tenant_scope( self, deployment_name, # type: str @@ -1099,25 +2627,15 @@ def cancel_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.cancel_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1130,6 +2648,7 @@ def cancel_at_tenant_scope( cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_tenant_scope_initial( self, deployment_name, # type: str @@ -1142,30 +2661,20 @@ def _validate_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_validate_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1184,8 +2693,11 @@ def _validate_at_tenant_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_tenant_scope( self, deployment_name, # type: str @@ -1202,15 +2714,20 @@ def begin_validate_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1221,25 +2738,21 @@ def begin_validate_at_tenant_scope( raw_result = self._validate_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1251,6 +2764,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_tenant_scope_initial( @@ -1265,30 +2779,20 @@ def _what_if_at_tenant_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_tenant_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_tenant_scope_request_initial( + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_tenant_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1296,21 +2800,25 @@ def _what_if_at_tenant_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_tenant_scope( self, deployment_name, # type: str @@ -1327,15 +2835,20 @@ def begin_what_if_at_tenant_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1346,25 +2859,21 @@ def begin_what_if_at_tenant_scope( raw_result = self._what_if_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1376,8 +2885,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_tenant_scope( self, deployment_name, # type: str @@ -1398,25 +2909,15 @@ def export_template_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_tenant_scope_request( + deployment_name=deployment_name, + template_url=self.export_template_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +2931,11 @@ def export_template_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_tenant_scope( self, filter=None, # type: Optional[str] @@ -1447,8 +2951,10 @@ def list_at_tenant_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -1456,34 +2962,31 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_tenant_scope_request( + filter=filter, + top=top, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1501,6 +3004,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -1518,26 +3022,16 @@ def _delete_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + template_url=self._delete_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1550,6 +3044,8 @@ def _delete_at_management_group_scope_initial( _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_management_group_scope( self, group_id, # type: str @@ -1573,15 +3069,17 @@ def begin_delete_at_management_group_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1595,20 +3093,14 @@ def begin_delete_at_management_group_scope( 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 = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1620,8 +3112,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_management_group_scope( self, group_id, # type: str @@ -1645,26 +3139,16 @@ def check_existence_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.check_existence_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1674,10 +3158,11 @@ def check_existence_at_management_group_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_management_group_scope_initial( self, group_id, # type: str @@ -1691,31 +3176,21 @@ def _create_or_update_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeployment') + + request = build_create_or_update_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1733,8 +3208,11 @@ def _create_or_update_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_management_group_scope( self, group_id, # type: str @@ -1755,15 +3233,20 @@ def begin_create_or_update_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -1775,26 +3258,21 @@ def begin_create_or_update_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -1806,8 +3284,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_management_group_scope( self, group_id, # type: str @@ -1831,26 +3311,16 @@ def get_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.get_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1864,8 +3334,11 @@ def get_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_management_group_scope( self, group_id, # type: str @@ -1894,26 +3367,16 @@ def cancel_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.cancel_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1926,6 +3389,7 @@ def cancel_at_management_group_scope( cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_management_group_scope_initial( self, group_id, # type: str @@ -1939,31 +3403,21 @@ def _validate_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScopedDeployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._validate_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1982,8 +3436,11 @@ def _validate_at_management_group_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_management_group_scope( self, group_id, # type: str @@ -2003,15 +3460,20 @@ def begin_validate_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2023,26 +3485,21 @@ def begin_validate_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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: @@ -2054,6 +3511,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_management_group_scope_initial( @@ -2069,31 +3527,21 @@ def _what_if_at_management_group_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_management_group_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') + + request = build_what_if_at_management_group_scope_request_initial( + group_id=group_id, + deployment_name=deployment_name, + content_type=content_type, + json=_json, + template_url=self._what_if_at_management_group_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedDeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2101,21 +3549,25 @@ def _what_if_at_management_group_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_management_group_scope( self, group_id, # type: str @@ -2135,15 +3587,20 @@ def begin_what_if_at_management_group_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ScopedDeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2155,26 +3612,21 @@ def begin_what_if_at_management_group_scope( group_id=group_id, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2186,8 +3638,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_management_group_scope( self, group_id, # type: str @@ -2211,26 +3665,16 @@ def export_template_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_management_group_scope_request( + group_id=group_id, + deployment_name=deployment_name, + template_url=self.export_template_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2244,8 +3688,11 @@ def export_template_at_management_group_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_management_group_scope( self, group_id, # type: str @@ -2264,8 +3711,10 @@ def list_at_management_group_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -2273,38 +3722,33 @@ def list_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - 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 top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + template_url=self.list_at_management_group_scope.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_at_management_group_scope_request( + group_id=group_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2322,6 +3766,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -2338,26 +3783,16 @@ def _delete_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2370,6 +3805,8 @@ def _delete_at_subscription_scope_initial( _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete_at_subscription_scope( self, deployment_name, # type: str @@ -2390,15 +3827,17 @@ def begin_delete_at_subscription_scope( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -2411,20 +3850,14 @@ def begin_delete_at_subscription_scope( 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 = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2436,8 +3869,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence_at_subscription_scope( self, deployment_name, # type: str @@ -2458,26 +3893,16 @@ def check_existence_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2487,10 +3912,11 @@ def check_existence_at_subscription_scope( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2503,31 +3929,21 @@ def _create_or_update_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2545,8 +3961,11 @@ def _create_or_update_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update_at_subscription_scope( self, deployment_name, # type: str @@ -2564,15 +3983,20 @@ def begin_create_or_update_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -2583,26 +4007,21 @@ def begin_create_or_update_at_subscription_scope( raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2614,8 +4033,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get_at_subscription_scope( self, deployment_name, # type: str @@ -2636,26 +4057,16 @@ def get_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2669,8 +4080,11 @@ def get_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel_at_subscription_scope( self, deployment_name, # type: str @@ -2696,26 +4110,16 @@ def cancel_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2728,6 +4132,7 @@ def cancel_at_subscription_scope( cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_at_subscription_scope_initial( self, deployment_name, # type: str @@ -2740,31 +4145,21 @@ def _validate_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_validate_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2783,8 +4178,11 @@ def _validate_at_subscription_scope_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate_at_subscription_scope( self, deployment_name, # type: str @@ -2801,15 +4199,20 @@ def begin_validate_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2820,26 +4223,21 @@ def begin_validate_at_subscription_scope( raw_result = self._validate_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -2851,6 +4249,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_at_subscription_scope_initial( @@ -2865,31 +4264,21 @@ def _what_if_at_subscription_scope_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_at_subscription_scope_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_at_subscription_scope_request_initial( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_at_subscription_scope_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -2897,21 +4286,25 @@ def _what_if_at_subscription_scope_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if_at_subscription_scope( self, deployment_name, # type: str @@ -2928,15 +4321,20 @@ def begin_what_if_at_subscription_scope( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -2947,26 +4345,21 @@ def begin_what_if_at_subscription_scope( raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -2978,8 +4371,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template_at_subscription_scope( self, deployment_name, # type: str @@ -3000,26 +4395,16 @@ def export_template_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template_at_subscription_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_at_subscription_scope_request( + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template_at_subscription_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3033,8 +4418,11 @@ def export_template_at_subscription_scope( return cls(pipeline_response, deserialized, {}) return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_at_subscription_scope( self, filter=None, # type: Optional[str] @@ -3050,8 +4438,10 @@ def list_at_subscription_scope( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3059,38 +4449,33 @@ def list_at_subscription_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_subscription_scope.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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + template_url=self.list_at_subscription_scope.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_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3108,6 +4493,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -3125,27 +4511,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3158,6 +4534,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -3183,15 +4561,17 @@ def begin_delete( :type deployment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -3205,21 +4585,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3231,8 +4604,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -3257,27 +4632,17 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3287,10 +4652,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -3304,32 +4670,22 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Deployment') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3347,8 +4703,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -3370,15 +4729,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentExtended or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] - :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 DeploymentExtended or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentExtended] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentExtended"] lro_delay = kwargs.pop( 'polling_interval', @@ -3390,27 +4754,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentExtended', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3422,8 +4780,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -3447,27 +4807,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # 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, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3481,8 +4831,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + @distributed_trace def cancel( self, resource_group_name, # type: str @@ -3511,27 +4864,17 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3544,6 +4887,7 @@ def cancel( cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + def _validate_initial( self, resource_group_name, # type: str @@ -3557,32 +4901,22 @@ def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Deployment') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Deployment') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3601,8 +4935,11 @@ def _validate_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + @distributed_trace def begin_validate( self, resource_group_name, # type: str @@ -3623,15 +4960,20 @@ def begin_validate( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.Deployment :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. + :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 DeploymentValidateResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] - :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 DeploymentValidateResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentValidateResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentValidateResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3643,27 +4985,21 @@ def begin_validate( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeploymentValidateResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - '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: @@ -3675,6 +5011,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( @@ -3690,32 +5027,22 @@ def _what_if_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._what_if_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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeploymentWhatIf') + + request = build_what_if_request_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._what_if_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3723,21 +5050,25 @@ def _what_if_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + @distributed_trace def begin_what_if( self, resource_group_name, # type: str @@ -3758,15 +5089,20 @@ def begin_what_if( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentWhatIf :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. + :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 WhatIfOperationResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] - :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 WhatIfOperationResult or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.WhatIfOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.WhatIfOperationResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -3778,27 +5114,21 @@ def begin_what_if( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('WhatIfOperationResult', 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\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, '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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -3810,8 +5140,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + @distributed_trace def export_template( self, resource_group_name, # type: str @@ -3835,27 +5167,17 @@ def export_template( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.export_template.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_export_template_request( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + template_url=self.export_template.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -3869,8 +5191,11 @@ def export_template( return cls(pipeline_response, deserialized, {}) return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -3890,8 +5215,10 @@ def list_by_resource_group( :param top: The number of results to get. If null is passed, returns all deployments. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeploymentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] + :return: An iterator like instance of either DeploymentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.DeploymentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeploymentListResult"] @@ -3899,39 +5226,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('DeploymentListResult', pipeline_response) + deserialized = self._deserialize("DeploymentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3949,11 +5272,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + @distributed_trace def calculate_template_hash( self, template, # type: Any @@ -3974,26 +5299,19 @@ def calculate_template_hash( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_template_hash.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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(template, 'object') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(template, 'object') + + request = build_calculate_template_hash_request( + content_type=content_type, + json=_json, + template_url=self.calculate_template_hash.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -4007,4 +5325,6 @@ def calculate_template_hash( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py index 6c9b9c954cc73..28908eee78c80 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.resources.v2021_04_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_provider_resource_types_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_provider_resource_types_operations.py index fb5156424a6c5..9a73994787215 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_provider_resource_types_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_provider_resource_types_operations.py @@ -5,23 +5,69 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProviderResourceTypesOperations(object): """ProviderResourceTypesOperations operations. @@ -44,6 +90,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_provider_namespace, # type: str @@ -68,28 +115,17 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -103,4 +139,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py index 1fe6971c00110..7676ed730c5fa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_providers_operations.py @@ -5,24 +5,312 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_unregister_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_at_management_group_scope_request( + resource_provider_namespace, # type: str + group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "groupId": _SERIALIZER.url("group_id", group_id, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_provider_permissions_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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_register_request( + resource_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_at_tenant_scope_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_provider_namespace, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, '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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_at_tenant_scope_request( + resource_provider_namespace, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/{resourceProviderNamespace}') + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -45,6 +333,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def unregister( self, resource_provider_namespace, # type: str @@ -65,26 +354,16 @@ def unregister( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.unregister.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_unregister_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.unregister.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -98,8 +377,11 @@ def unregister( return cls(pipeline_response, deserialized, {}) return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + @distributed_trace def register_at_management_group_scope( self, resource_provider_namespace, # type: str @@ -123,26 +405,16 @@ def register_at_management_group_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.register_at_management_group_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_register_at_management_group_scope_request( + resource_provider_namespace=resource_provider_namespace, + group_id=group_id, + template_url=self.register_at_management_group_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -155,6 +427,8 @@ def register_at_management_group_scope( register_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def provider_permissions( self, resource_provider_namespace, # type: str @@ -175,26 +449,16 @@ def provider_permissions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.provider_permissions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_provider_permissions_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + template_url=self.provider_permissions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -208,8 +472,11 @@ def provider_permissions( return cls(pipeline_response, deserialized, {}) return deserialized + provider_permissions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions'} # type: ignore + + @distributed_trace def register( self, resource_provider_namespace, # type: str @@ -233,34 +500,24 @@ def register( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.register.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if properties is not None: - body_content = self._serialize.body(properties, 'ProviderRegistrationRequest') + _json = self._serialize.body(properties, 'ProviderRegistrationRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_register_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.register.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -274,8 +531,11 @@ def register( return cls(pipeline_response, deserialized, {}) return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + @distributed_trace def list( self, expand=None, # type: Optional[str] @@ -290,7 +550,8 @@ def list( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -298,36 +559,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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, + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -345,11 +601,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + @distributed_trace def list_at_tenant_scope( self, expand=None, # type: Optional[str] @@ -364,7 +622,8 @@ def list_at_tenant_scope( :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ProviderListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderListResult"] @@ -372,32 +631,29 @@ def list_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_at_tenant_scope.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_at_tenant_scope_request( + expand=expand, + template_url=self.list_at_tenant_scope.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_at_tenant_scope_request( + expand=expand, + 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('ProviderListResult', pipeline_response) + deserialized = self._deserialize("ProviderListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -415,11 +671,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + @distributed_trace def get( self, resource_provider_namespace, # type: str @@ -444,28 +702,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'subscriptionId': self._serialize.url("self._config.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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -479,8 +726,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + @distributed_trace def get_at_tenant_scope( self, resource_provider_namespace, # type: str @@ -505,27 +755,16 @@ def get_at_tenant_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_tenant_scope_request( + resource_provider_namespace=resource_provider_namespace, + expand=expand, + template_url=self.get_at_tenant_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -539,4 +778,6 @@ def get_at_tenant_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resource_groups_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resource_groups_operations.py index b4b20ab042731..188132b3293de 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resource_groups_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resource_groups_operations.py @@ -5,26 +5,293 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_existence_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + force_deletion_types = kwargs.pop('force_deletion_types', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + if force_deletion_types is not None: + query_parameters['forceDeletionTypes'] = _SERIALIZER.query("force_deletion_types", force_deletion_types, '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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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_update_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}') + 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] + 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, + **kwargs + ) + + +def build_export_template_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate') + 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), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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 + ) + +# fmt: on class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. @@ -47,6 +314,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -68,26 +336,16 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -97,10 +355,12 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -126,31 +386,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourceGroup') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -168,8 +418,10 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -182,28 +434,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.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 force_deletion_types is not None: - query_parameters['forceDeletionTypes'] = self._serialize.query("force_deletion_types", force_deletion_types, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + force_deletion_types=force_deletion_types, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,6 +457,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -237,15 +480,17 @@ def begin_delete( :type force_deletion_types: 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -259,20 +504,14 @@ def begin_delete( 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 = { - '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'), - } - 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: @@ -284,8 +523,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -307,26 +548,16 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -340,8 +571,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -370,31 +604,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourceGroupPatchable') + + request = build_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -408,8 +632,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + def _export_template_initial( self, resource_group_name, # type: str @@ -422,31 +648,21 @@ def _export_template_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._export_template_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), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ExportTemplateRequest') + + request = build_export_template_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._export_template_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -462,8 +678,11 @@ def _export_template_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + @distributed_trace def begin_export_template( self, resource_group_name, # type: str @@ -479,15 +698,20 @@ def begin_export_template( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ExportTemplateRequest :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. + :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 ResourceGroupExportResult or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] - :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 ResourceGroupExportResult or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupExportResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupExportResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -498,26 +722,21 @@ def begin_export_template( raw_result = self._export_template_initial( resource_group_name=resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if cls: 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), - } - 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, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -529,8 +748,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -547,8 +768,10 @@ def list( :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] + :return: An iterator like instance of either ResourceGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceGroupListResult"] @@ -556,38 +779,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + top=top, + 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, + filter=filter, + top=top, + 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('ResourceGroupListResult', pipeline_response) + deserialized = self._deserialize("ResourceGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,6 +823,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py index af4a11d09c0e4..fd4d5d39ccf26 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_resources_operations.py @@ -5,26 +5,588 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_validate_move_resources_request_initial( + source_resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources') + path_format_arguments = { + "sourceResourceGroupName": _SERIALIZER.url("source_resource_group_name", source_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] + 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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + expand = kwargs.pop('expand', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resources') + 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] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + 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_check_existence_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_create_or_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_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_check_existence_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="HEAD", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_create_or_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_by_id_request_initial( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_by_id_request( + resource_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version') # type: str + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class ResourcesOperations(object): """ResourcesOperations operations. @@ -47,6 +609,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -79,11 +642,12 @@ def list_by_resource_group( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -91,41 +655,37 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,6 +703,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -160,31 +721,21 @@ def _move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -197,6 +748,8 @@ def _move_resources_initial( _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + @distributed_trace def begin_move_resources( self, source_resource_group_name, # type: str @@ -218,15 +771,18 @@ def begin_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -237,23 +793,18 @@ def begin_move_resources( raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -265,6 +816,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( @@ -279,31 +831,21 @@ def _validate_move_resources_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_move_resources_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ResourcesMoveInfo') + + request = build_validate_move_resources_request_initial( + source_resource_group_name=source_resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._validate_move_resources_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -316,6 +858,8 @@ def _validate_move_resources_initial( _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + @distributed_trace def begin_validate_move_resources( self, source_resource_group_name, # type: str @@ -339,15 +883,18 @@ def begin_validate_move_resources( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.ResourcesMoveInfo :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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -358,23 +905,18 @@ def begin_validate_move_resources( raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_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'), - } - 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: @@ -386,8 +928,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -409,15 +953,16 @@ def list( currently-supported properties: ``name`` and ``resourceGroup``\ :code:`
`:code:`
`For example, to get all resources with 'demo' anywhere in the resource name, use ``$filter=substringof('demo', name)``\ :code:`
`:code:`
`Multiple substring operations - can also be combined using ``and``\ /\ ``or`` - operators.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and - values. For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and - tagValue eq 'Value1'``. Note that when resources are filtered by tag name and value, - :code:`the original tags for each resource will not be returned in the results.` Any - list of additional properties queried via ``$expand`` may also not be compatible when filtering - by tag names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by - prefix using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will - return all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , + can also be combined using ``and``\ /\ ``or`` operators.:code:`
`:code:`
`Note that any + truncated number of results queried via ``$top`` may also not be compatible when using a + filter.:code:`
`:code:`
`:code:`
`Resources can be filtered by tag names and values. + For example, to filter for a tag name and value, use ``$filter=tagName eq 'tag1' and tagValue + eq 'Value1'``. Note that when resources are filtered by tag name and value, :code:`the + original tags for each resource will not be returned in the results.` Any list of + additional properties queried via ``$expand`` may also not be compatible when filtering by tag + names/values. :code:`
`:code:`
`For tag names only, resources can be filtered by prefix + using the following syntax: ``$filter=startswith(tagName, 'depart')``. This query will return + all resources with a tag name prefixed by the phrase ``depart`` (i.e.\ ``department``\ , ``departureDate``\ , ``departureTime``\ , etc.):code:`
`:code:`
`:code:`
`Note that some properties can be combined when filtering resources, which include the following: ``substringof() and/or resourceType``\ , ``plan and plan/publisher and plan/name``\ , and @@ -427,11 +972,12 @@ def list( Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, ``$expand=createdTime,changedTime``. :type expand: str - :param top: The maximum number of results to return. If null is passed, returns all resources. + :param top: The number of results to return. If null is passed, returns all resources. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.ResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] @@ -439,40 +985,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - 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, + filter=filter, + expand=expand, + top=top, + 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, + filter=filter, + expand=expand, + top=top, + 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('ResourceListResult', pipeline_response) + deserialized = self._deserialize("ResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -490,11 +1031,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + @distributed_trace def check_existence( self, resource_group_name, # type: str @@ -531,29 +1074,21 @@ def check_existence( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_existence.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -563,10 +1098,11 @@ def check_existence( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -583,29 +1119,21 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -618,6 +1146,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -646,15 +1176,17 @@ def begin_delete( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -672,24 +1204,14 @@ def begin_delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -701,6 +1223,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( @@ -720,34 +1243,26 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -766,8 +1281,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -799,15 +1317,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -823,30 +1346,21 @@ def begin_create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -858,6 +1372,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( @@ -877,34 +1392,26 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenericResource') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -920,8 +1427,11 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, resource_group_name, # type: str @@ -953,15 +1463,20 @@ def begin_update( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -977,30 +1492,21 @@ def begin_update( resource_name=resource_name, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_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: @@ -1012,8 +1518,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -1050,29 +1558,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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\._\(\)]+$'), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_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) response = pipeline_response.http_response @@ -1086,8 +1586,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + @distributed_trace def check_existence_by_id( self, resource_id, # type: str @@ -1113,24 +1616,16 @@ def check_existence_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.check_existence_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_check_existence_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.check_existence_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1140,10 +1635,11 @@ def check_existence_by_id( if cls: return cls(pipeline_response, None, {}) - return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + def _delete_by_id_initial( self, resource_id, # type: str @@ -1156,24 +1652,16 @@ def _delete_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self._delete_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request_initial( + resource_id=resource_id, + api_version=api_version, + template_url=self._delete_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1186,6 +1674,8 @@ def _delete_by_id_initial( _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_delete_by_id( self, resource_id, # type: str @@ -1203,15 +1693,17 @@ def begin_delete_by_id( :type 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. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -1225,19 +1717,14 @@ def begin_delete_by_id( 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 = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1249,6 +1736,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( @@ -1264,29 +1752,21 @@ def _create_or_update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._create_or_update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1305,8 +1785,11 @@ def _create_or_update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_create_or_update_by_id( self, resource_id, # type: str @@ -1327,15 +1810,20 @@ def begin_create_or_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1347,25 +1835,21 @@ def begin_create_or_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1377,6 +1861,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( @@ -1392,29 +1877,21 @@ def _update_by_id_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - # Construct URL - url = self._update_by_id_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + 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(parameters, 'GenericResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_by_id_request_initial( + resource_id=resource_id, + content_type=content_type, + api_version=api_version, + json=_json, + template_url=self._update_by_id_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GenericResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1430,8 +1907,11 @@ def _update_by_id_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + @distributed_trace def begin_update_by_id( self, resource_id, # type: str @@ -1452,15 +1932,20 @@ def begin_update_by_id( :type parameters: ~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource :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. + :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 GenericResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] - :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 GenericResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2021_04_01.models.GenericResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -1472,25 +1957,21 @@ def begin_update_by_id( resource_id=resource_id, api_version=api_version, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GenericResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - 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: @@ -1502,8 +1983,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + @distributed_trace def get_by_id( self, resource_id, # type: str @@ -1529,24 +2012,16 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -1560,4 +2035,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_tags_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_tags_operations.py index b671d8fbb4550..cd373770eef2c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_tags_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2021_04_01/operations/_tags_operations.py @@ -5,24 +5,340 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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_create_or_update_value_request( + tag_name, # type: str + tag_value, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_name, 'str'), + "tagValue": _SERIALIZER.url("tag_value", tag_value, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + tag_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames/{tagName}') + path_format_arguments = { + "tagName": _SERIALIZER.url("tag_name", tag_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_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/tagNames') + 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 + ) + + +def build_create_or_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_at_scope_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Resources/tags/default') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -45,6 +361,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete_value( self, tag_name, # type: str @@ -72,27 +389,17 @@ def delete_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.delete_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -105,6 +412,8 @@ def delete_value( delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update_value( self, tag_name, # type: str @@ -131,27 +440,17 @@ def create_or_update_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update_value.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'tagValue': self._serialize.url("tag_value", tag_value, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_value_request( + tag_name=tag_name, + tag_value=tag_value, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update_value.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +468,11 @@ def create_or_update_value( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + @distributed_trace def create_or_update( self, tag_name, # type: str @@ -196,26 +498,16 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -233,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def delete( self, tag_name, # type: str @@ -259,26 +554,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'tagName': self._serialize.url("tag_name", tag_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + tag_name=tag_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -291,6 +576,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -305,7 +592,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2021_04_01.models.TagsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsListResult"] @@ -313,34 +601,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagsListResult', pipeline_response) + deserialized = self._deserialize("TagsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -358,11 +641,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + @distributed_trace def create_or_update_at_scope( self, scope, # type: str @@ -389,30 +674,20 @@ def create_or_update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.create_or_update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -426,8 +701,11 @@ def create_or_update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def update_at_scope( self, scope, # type: str @@ -458,30 +736,20 @@ def update_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_at_scope_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.update_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagsPatchResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -495,8 +763,11 @@ def update_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def get_at_scope( self, scope, # type: str @@ -519,25 +790,15 @@ def get_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - # Construct URL - url = self.get_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_at_scope_request( + scope=scope, + template_url=self.get_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -551,8 +812,11 @@ def get_at_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + @distributed_trace def delete_at_scope( self, scope, # type: str @@ -575,25 +839,15 @@ def delete_at_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - # Construct URL - url = self.delete_at_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_at_scope_request( + scope=scope, + template_url=self.delete_at_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -605,3 +859,4 @@ def delete_at_scope( return cls(pipeline_response, None, {}) delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py index 83b9e3ae9428b..1b8231b4efc0b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py index ed151630858ff..90ba360b546c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_operations_mixin.py @@ -10,16 +10,10 @@ # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + from typing import Any, Optional class SubscriptionClientOperationsMixin(object): @@ -29,6 +23,7 @@ def check_resource_name( resource_name_definition=None, # type: Optional["_models.ResourceName"] **kwargs # type: Any ): + # type: (...) -> "_models.CheckResourceNameResult" """Checks resource name validity. A resource name is valid if it is not a reserved word, does not contains a reserved word and @@ -36,7 +31,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py index 915c656beced1..c0320a38cc5db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/_subscription_client.py @@ -24,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -68,12 +67,10 @@ def __init__( self, credential, # type: "TokenCredential" api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = SubscriptionClientConfiguration(credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(SubscriptionClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py index 62d3c90dbde7b..d27af02f17ccd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_configuration.py @@ -12,7 +12,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 @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py index 7ab07ebf2f8b8..dd2eeef23e278 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_operations_mixin.py @@ -9,13 +9,7 @@ # regenerated. # -------------------------------------------------------------------------- from msrest import Serializer, Deserializer -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat +from typing import Any, Optional class SubscriptionClientOperationsMixin(object): @@ -32,7 +26,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py index a9abc20407d72..55be802a491a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/aio/_subscription_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -22,6 +21,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -66,12 +66,10 @@ def __init__( self, credential: "AsyncTokenCredential", api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = SubscriptionClientConfiguration(credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(SubscriptionClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py index 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py index ec445a28d37a5..36844b714a52a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2016-06-01" @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json index fd9d33b0cdb02..2e67f81626731 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -91,18 +90,18 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "resource_name_definition" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py index 5384bcbcb3e64..ccc99a114c9c0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_subscription_client.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -32,52 +29,61 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2016_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py index 923b30a4e25f3..5bb6221ecef98 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2016-06-01" @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py index a773b6b1fe9f4..cb18105bcbc64 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.TenantsOperations + :vartype tenants: + azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py index 9d9e2d9759468..73f110300ba7a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.subscriptions.v2016_06_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py index 058e383a4911f..1f0ea5ed0e478 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscription_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_client_operations import build_check_resource_name_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionClientOperationsMixin: + @distributed_trace_async async def check_resource_name( self, resource_name_definition: Optional["_models.ResourceName"] = None, @@ -32,7 +37,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult @@ -43,35 +49,28 @@ async def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -80,4 +79,6 @@ async def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py index 936ba9ba68ecf..1d84aa44ad70a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_subscriptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id: str, @@ -55,7 +61,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -63,34 +70,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,11 +110,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace_async async def get( self, subscription_id: str, @@ -132,25 +136,15 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -173,8 +170,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -182,30 +181,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,6 +219,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py index c583f593ae262..d9c40a6cae12d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations/_tenants_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tenants_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models.py index 011eca63f9537..5b1a6c68a5e07 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models.py @@ -13,13 +13,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -32,6 +33,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -41,10 +52,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -56,6 +67,12 @@ def __init__( self, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) @@ -64,8 +81,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition """ _attribute_map = { @@ -76,6 +93,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -134,8 +157,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] """ _attribute_map = { @@ -146,6 +169,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -153,10 +180,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay """ _attribute_map = { @@ -168,6 +195,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -176,14 +209,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -197,6 +230,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -207,10 +250,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -222,6 +265,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -232,10 +281,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -252,6 +301,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = kwargs['name'] self.type = kwargs['type'] @@ -272,13 +327,13 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str + :vartype authorization_source: str """ _validation = { @@ -301,6 +356,15 @@ def __init__( self, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -315,10 +379,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -334,6 +398,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -372,6 +442,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -404,6 +476,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -414,10 +488,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -433,6 +507,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py index b6e20cf666d51..a4d1af36c1fdc 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_models_py3.py @@ -17,13 +17,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -40,6 +41,16 @@ def __init__( status: Optional[Union[str, "ResourceNameStatus"]] = None, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = name self.type = type @@ -49,10 +60,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -67,6 +78,12 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = message self.code = code @@ -75,8 +92,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition """ _attribute_map = { @@ -89,6 +106,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -135,6 +156,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -147,8 +170,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] """ _attribute_map = { @@ -161,6 +184,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = value @@ -168,10 +195,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay """ _attribute_map = { @@ -186,6 +213,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -194,14 +227,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -220,6 +253,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -230,10 +273,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -248,6 +291,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -258,10 +307,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -281,6 +330,12 @@ def __init__( type: str, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = name self.type = type @@ -301,13 +356,13 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str + :vartype authorization_source: str """ _validation = { @@ -333,6 +388,15 @@ def __init__( authorization_source: Optional[str] = None, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -347,10 +411,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -369,6 +433,12 @@ def __init__( value: Optional[List["Subscription"]] = None, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -407,6 +477,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -439,6 +511,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -449,10 +523,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -471,6 +545,13 @@ def __init__( value: Optional[List["TenantIdDescription"]] = None, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py index cec9f01471ec7..6465a926ff236 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_subscription_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 ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Is the resource name Allowed or Reserved """ ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ @@ -41,7 +26,7 @@ class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py index e74467ae86094..765edc1047d6f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.subscriptions.v2016_06_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscription_client_operations.py index 650d692b7a663..ee0c640bc3185 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscription_client_operations.py @@ -5,25 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_resource_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/checkResourceName') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class SubscriptionClientOperationsMixin(object): + @distributed_trace def check_resource_name( self, resource_name_definition=None, # type: Optional["_models.ResourceName"] @@ -37,7 +76,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2016_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.CheckResourceNameResult @@ -48,35 +88,28 @@ def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -85,4 +118,6 @@ def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscriptions_operations.py index c8c457fd00b35..3482abd9be140 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_subscriptions_operations.py @@ -5,24 +5,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_locations_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + 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 + ) + + +def build_get_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + 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 + ) + + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,6 +143,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id, # type: str @@ -60,7 +159,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -68,34 +168,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +208,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace def get( self, subscription_id, # type: str @@ -138,25 +235,15 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +257,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -180,8 +270,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -189,30 +281,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -230,6 +319,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_tenants_operations.py index 4d90432ece489..e199c2e714d01 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/_tenants_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/tenants') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TenantsOperations(object): """TenantsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py index 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py index 5c7dab6f77de2..a8ecddfa60786 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-06-01" @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json index 45847e7813160..7852d2553636f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -91,18 +90,18 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "resource_name_definition" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py index 58ff30318988c..28c3fd94fb9cd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_subscription_client.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -32,52 +29,61 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py index 735a17799ec53..de362bd8bea7e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-06-01" @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py index b739ce48b0fd4..d169683b428fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.TenantsOperations + :vartype tenants: + azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py index 8fd054170f995..67e5d32408983 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.subscriptions.v2018_06_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py index 119ea610e50f3..d04a0245450fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscription_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_client_operations import build_check_resource_name_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionClientOperationsMixin: + @distributed_trace_async async def check_resource_name( self, resource_name_definition: Optional["_models.ResourceName"] = None, @@ -32,7 +37,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult @@ -43,35 +49,28 @@ async def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -80,4 +79,6 @@ async def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py index 396fbf1b47799..e186f6c2b670a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_subscriptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id: str, @@ -55,7 +61,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -63,34 +70,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,11 +110,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace_async async def get( self, subscription_id: str, @@ -132,25 +136,15 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -173,8 +170,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -182,30 +181,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,6 +219,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py index 051589a63229e..45495b140d93b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations/_tenants_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tenants_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models.py index e7f7b644f9b0c..f0266124c8992 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models.py @@ -13,13 +13,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -32,6 +33,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -41,10 +52,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -56,6 +67,12 @@ def __init__( self, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) @@ -64,8 +81,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition """ _attribute_map = { @@ -76,6 +93,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -134,8 +157,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] """ _attribute_map = { @@ -146,6 +169,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -153,10 +180,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay """ _attribute_map = { @@ -168,6 +195,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -176,14 +209,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -197,6 +230,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -207,10 +250,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -222,6 +265,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -232,10 +281,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -252,6 +301,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = kwargs['name'] self.type = kwargs['type'] @@ -274,13 +329,13 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str + :vartype authorization_source: str """ _validation = { @@ -305,6 +360,15 @@ def __init__( self, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -320,10 +384,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -339,6 +403,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -377,6 +447,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -425,6 +497,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -439,10 +513,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -458,6 +532,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py index c0e1457f1a77e..81ca5a0903e00 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_models_py3.py @@ -17,13 +17,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -40,6 +41,16 @@ def __init__( status: Optional[Union[str, "ResourceNameStatus"]] = None, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = name self.type = type @@ -49,10 +60,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -67,6 +78,12 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = message self.code = code @@ -75,8 +92,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition """ _attribute_map = { @@ -89,6 +106,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -135,6 +156,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -147,8 +170,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] """ _attribute_map = { @@ -161,6 +184,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = value @@ -168,10 +195,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay """ _attribute_map = { @@ -186,6 +213,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -194,14 +227,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -220,6 +253,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -230,10 +273,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -248,6 +291,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -258,10 +307,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -281,6 +330,12 @@ def __init__( type: str, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = name self.type = type @@ -303,13 +358,13 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str + :vartype authorization_source: str """ _validation = { @@ -337,6 +392,15 @@ def __init__( authorization_source: Optional[str] = None, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -352,10 +416,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -374,6 +438,12 @@ def __init__( value: Optional[List["Subscription"]] = None, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -412,6 +482,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -460,6 +532,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -474,10 +548,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -496,6 +570,13 @@ def __init__( value: Optional[List["TenantIdDescription"]] = None, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py index cec9f01471ec7..6465a926ff236 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_subscription_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 ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Is the resource name Allowed or Reserved """ ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ @@ -41,7 +26,7 @@ class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py index c99cf978c0988..28e316b95512b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.subscriptions.v2018_06_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscription_client_operations.py index afdf25b06eead..bd3276c685758 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscription_client_operations.py @@ -5,25 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_resource_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/checkResourceName') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class SubscriptionClientOperationsMixin(object): + @distributed_trace def check_resource_name( self, resource_name_definition=None, # type: Optional["_models.ResourceName"] @@ -37,7 +76,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2018_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.CheckResourceNameResult @@ -48,35 +88,28 @@ def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -85,4 +118,6 @@ def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscriptions_operations.py index 612fee5574c7a..718562397c36c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_subscriptions_operations.py @@ -5,24 +5,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_locations_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + 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 + ) + + +def build_get_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + 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 + ) + + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,6 +143,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id, # type: str @@ -60,7 +159,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -68,34 +168,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +208,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace def get( self, subscription_id, # type: str @@ -138,25 +235,15 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +257,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -180,8 +270,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -189,30 +281,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -230,6 +319,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_tenants_operations.py index 5da05238bbb0a..71fe157a0bc4e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/_tenants_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/tenants') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TenantsOperations(object): """TenantsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py index 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py index 4d9c0120aacfd..31ac3597b380a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2019-06-01" @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json index 54a53baf719a2..973d2ca48373b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -91,18 +90,18 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "resource_name_definition" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py index 28fa33abddead..66221cd123c4c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_subscription_client.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -32,52 +29,61 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py index aca9c969abe3e..f23a4da090868 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2019-06-01" @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py index f8ab1eb9091ba..cddf60ffe3aee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.TenantsOperations + :vartype tenants: + azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py index 15d0a0ebdda51..12a652410f5b4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.subscriptions.v2019_06_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py index 6ea42433ed71a..b6dc332c028e2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscription_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_client_operations import build_check_resource_name_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionClientOperationsMixin: + @distributed_trace_async async def check_resource_name( self, resource_name_definition: Optional["_models.ResourceName"] = None, @@ -32,7 +37,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult @@ -43,35 +49,28 @@ async def check_resource_name( 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.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -80,4 +79,6 @@ async def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py index b9a0affc1a148..61d9b8cc7fd0e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_subscriptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id: str, @@ -55,7 +61,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -63,34 +70,29 @@ def list_locations( 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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,11 +110,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace_async async def get( self, subscription_id: str, @@ -132,25 +136,15 @@ 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("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -173,8 +170,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -182,30 +181,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,6 +219,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py index a77d20786f7ec..3a23d63d91282 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations/_tenants_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tenants_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models.py index 098139fbac4fd..7dd05f7e59903 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models.py @@ -13,13 +13,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -32,6 +33,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -41,10 +52,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -56,6 +67,12 @@ def __init__( self, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) @@ -64,8 +81,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition """ _attribute_map = { @@ -76,6 +93,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -122,6 +143,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -134,8 +157,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] """ _attribute_map = { @@ -146,6 +169,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -171,6 +198,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -178,10 +207,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay """ _attribute_map = { @@ -193,6 +222,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -201,14 +236,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -222,6 +257,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -232,10 +277,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -247,6 +292,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -257,10 +308,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -277,6 +328,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = kwargs['name'] self.type = kwargs['type'] @@ -299,15 +356,15 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] """ @@ -334,6 +391,18 @@ def __init__( self, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -350,10 +419,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -369,6 +438,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -407,6 +482,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -461,6 +538,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -476,10 +555,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -495,6 +574,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py index 9187caff6e222..b6b9b430b0577 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_models_py3.py @@ -17,13 +17,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus """ _attribute_map = { @@ -40,6 +41,16 @@ def __init__( status: Optional[Union[str, "ResourceNameStatus"]] = None, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = name self.type = type @@ -49,10 +60,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -67,6 +78,12 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = message self.code = code @@ -75,8 +92,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition """ _attribute_map = { @@ -89,6 +106,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -135,6 +156,8 @@ def __init__( self, **kwargs ): + """ + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -147,8 +170,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] """ _attribute_map = { @@ -161,6 +184,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = value @@ -186,6 +213,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -193,10 +222,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay """ _attribute_map = { @@ -211,6 +240,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -219,14 +254,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -245,6 +280,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -255,10 +300,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -273,6 +318,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -283,10 +334,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -306,6 +357,12 @@ def __init__( type: str, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = name self.type = type @@ -328,15 +385,15 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] """ @@ -367,6 +424,18 @@ def __init__( managed_by_tenants: Optional[List["ManagedByTenant"]] = None, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -383,10 +452,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -405,6 +474,12 @@ def __init__( value: Optional[List["Subscription"]] = None, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -443,6 +518,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -497,6 +574,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -512,10 +591,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -534,6 +613,13 @@ def __init__( value: Optional[List["TenantIdDescription"]] = None, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py index 22d3c7855566e..cf21cf34210ce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_subscription_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 ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Is the resource name Allowed or Reserved """ ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ @@ -41,7 +26,7 @@ class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ @@ -51,7 +36,7 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The tenant category. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py index be368fc444701..310bc8547e1f3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.subscriptions.v2019_06_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscription_client_operations.py index f3fbe981e3908..a92a8c9d2d7a0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscription_client_operations.py @@ -5,25 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_resource_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/checkResourceName') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class SubscriptionClientOperationsMixin(object): + @distributed_trace def check_resource_name( self, resource_name_definition=None, # type: Optional["_models.ResourceName"] @@ -37,7 +76,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_06_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.CheckResourceNameResult @@ -48,35 +88,28 @@ def check_resource_name( 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.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -85,4 +118,6 @@ def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscriptions_operations.py index c104334b4c8a7..110238b5b3406 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_subscriptions_operations.py @@ -5,24 +5,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_locations_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + 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 + ) + + +def build_get_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + 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 + ) + + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,6 +143,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id, # type: str @@ -60,7 +159,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -68,34 +168,29 @@ def list_locations( 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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +208,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace def get( self, subscription_id, # type: str @@ -138,25 +235,15 @@ 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("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +257,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -180,8 +270,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -189,30 +281,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -230,6 +319,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_tenants_operations.py index d2bf4bfe45f48..f0ade4062b843 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/_tenants_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/tenants') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TenantsOperations(object): """TenantsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py index 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py index a99478d8b37dd..bbac3d159bdec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2019-11-01" @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json index cd790642ce1cd..00d1fed9332dd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -91,18 +90,18 @@ "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "resource_name_definition" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py index 23d7c358512ba..a37e051b79c8e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_subscription_client.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. @@ -32,52 +29,61 @@ class SubscriptionClient(SubscriptionClientOperationsMixin): :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2019_11_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py index 51532926985cc..6180a0a4b26fa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2019-11-01" @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py index 4ef27c1a4b6b8..71db93432075d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import Operations, SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -from .operations import Operations -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.Operations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.TenantsOperations + :vartype tenants: + azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py index f5588e46db1e9..28f04aabc4557 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.resource.subscriptions.v2019_11_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py index 9e3c80511e8b7..b8b0a9d8722c5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscription_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_client_operations import build_check_resource_name_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionClientOperationsMixin: + @distributed_trace_async async def check_resource_name( self, resource_name_definition: Optional["_models.ResourceName"] = None, @@ -32,7 +37,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult @@ -43,35 +49,28 @@ async def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -80,4 +79,6 @@ async def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py index 748e3bca79ad8..7a98968bbdf59 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_subscriptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id: str, @@ -55,7 +61,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -63,34 +70,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,11 +110,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace_async async def get( self, subscription_id: str, @@ -132,25 +136,15 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -164,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -173,8 +170,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -182,30 +181,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,6 +219,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py index 508c62b0a6d33..8beb30d5d9490 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations/_tenants_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tenants_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models.py index cd7ffe3605941..aaf20d20bccb1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models.py @@ -13,13 +13,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus """ _attribute_map = { @@ -32,6 +33,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -41,10 +52,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -56,6 +67,12 @@ def __init__( self, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = kwargs.get('message', None) self.code = kwargs.get('code', None) @@ -64,8 +81,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition """ _attribute_map = { @@ -76,6 +93,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -96,8 +117,8 @@ class Location(msrest.serialization.Model): :vartype display_name: str :ivar regional_display_name: The display name of the location and its region. :vartype regional_display_name: str - :param metadata: Metadata of the location, such as lat/long, paired region, and others. - :type metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + :ivar metadata: Metadata of the location, such as lat/long, paired region, and others. + :vartype metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata """ _validation = { @@ -121,6 +142,10 @@ def __init__( self, **kwargs ): + """ + :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. + :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -133,8 +158,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] """ _attribute_map = { @@ -145,6 +170,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -168,8 +197,9 @@ class LocationMetadata(msrest.serialization.Model): :vartype latitude: str :ivar physical_location: The physical location of the Azure location. :vartype physical_location: str - :param paired_region: The regions paired to this region. - :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + :ivar paired_region: The regions paired to this region. + :vartype paired_region: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] """ _validation = { @@ -195,6 +225,11 @@ def __init__( self, **kwargs ): + """ + :keyword paired_region: The regions paired to this region. + :paramtype paired_region: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + """ super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -226,6 +261,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -233,10 +270,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay """ _attribute_map = { @@ -248,6 +285,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -256,14 +299,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -277,6 +320,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -287,10 +340,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -302,6 +355,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -337,6 +396,8 @@ def __init__( self, **kwargs ): + """ + """ super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None @@ -348,10 +409,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -368,6 +429,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = kwargs['name'] self.type = kwargs['type'] @@ -390,18 +457,18 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :param tags: A set of tags. The tags attached to the subscription. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags attached to the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -428,6 +495,20 @@ def __init__( self, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] + :keyword tags: A set of tags. The tags attached to the subscription. + :paramtype tags: dict[str, str] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -445,10 +526,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -464,6 +545,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -502,6 +589,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -556,6 +645,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -571,10 +662,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -590,6 +681,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py index b1564c2e4008c..937b9e9515ed5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_models_py3.py @@ -17,13 +17,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus """ _attribute_map = { @@ -40,6 +41,16 @@ def __init__( status: Optional[Union[str, "ResourceNameStatus"]] = None, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = name self.type = type @@ -49,10 +60,10 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why resource name is invalid. - :param message: Description of the error. - :type message: str - :param code: Code of the error. - :type code: str + :ivar message: Description of the error. + :vartype message: str + :ivar code: Code of the error. + :vartype code: str """ _attribute_map = { @@ -67,6 +78,12 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword message: Description of the error. + :paramtype message: str + :keyword code: Code of the error. + :paramtype code: str + """ super(ErrorDefinition, self).__init__(**kwargs) self.message = message self.code = code @@ -75,8 +92,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition """ _attribute_map = { @@ -89,6 +106,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -109,8 +130,8 @@ class Location(msrest.serialization.Model): :vartype display_name: str :ivar regional_display_name: The display name of the location and its region. :vartype regional_display_name: str - :param metadata: Metadata of the location, such as lat/long, paired region, and others. - :type metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + :ivar metadata: Metadata of the location, such as lat/long, paired region, and others. + :vartype metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata """ _validation = { @@ -136,6 +157,10 @@ def __init__( metadata: Optional["LocationMetadata"] = None, **kwargs ): + """ + :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. + :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationMetadata + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -148,8 +173,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] """ _attribute_map = { @@ -162,6 +187,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = value @@ -185,8 +214,9 @@ class LocationMetadata(msrest.serialization.Model): :vartype latitude: str :ivar physical_location: The physical location of the Azure location. :vartype physical_location: str - :param paired_region: The regions paired to this region. - :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + :ivar paired_region: The regions paired to this region. + :vartype paired_region: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] """ _validation = { @@ -214,6 +244,11 @@ def __init__( paired_region: Optional[List["PairedRegion"]] = None, **kwargs ): + """ + :keyword paired_region: The regions paired to this region. + :paramtype paired_region: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] + """ super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -245,6 +280,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -252,10 +289,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay """ _attribute_map = { @@ -270,6 +307,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -278,14 +321,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -304,6 +347,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -314,10 +367,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -332,6 +385,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -367,6 +426,8 @@ def __init__( self, **kwargs ): + """ + """ super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None @@ -378,10 +439,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -401,6 +462,12 @@ def __init__( type: str, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = name self.type = type @@ -423,18 +490,18 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :param tags: A set of tags. The tags attached to the subscription. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags attached to the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -466,6 +533,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] + :keyword tags: A set of tags. The tags attached to the subscription. + :paramtype tags: dict[str, str] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -483,10 +564,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -505,6 +586,12 @@ def __init__( value: Optional[List["Subscription"]] = None, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -543,6 +630,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -597,6 +686,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -612,10 +703,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -634,6 +725,13 @@ def __init__( value: Optional[List["TenantIdDescription"]] = None, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py index 94c6f35f02b33..094df5177e457 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_subscription_client_enums.py @@ -6,48 +6,33 @@ # 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 RegionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RegionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The category of the region. """ RECOMMENDED = "Recommended" OTHER = "Other" -class RegionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RegionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the region. """ PHYSICAL = "Physical" LOGICAL = "Logical" -class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Is the resource name Allowed or Reserved """ ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ @@ -55,7 +40,7 @@ class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ @@ -65,7 +50,7 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Category of the tenant. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py index 199a5274f6af3..49e2b9adc61d3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :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.resource.subscriptions.v2019_11_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscription_client_operations.py index 071db31b0cbe3..69bc2e8743ce0 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscription_client_operations.py @@ -5,25 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_resource_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/checkResourceName') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class SubscriptionClientOperationsMixin(object): + @distributed_trace def check_resource_name( self, resource_name_definition=None, # type: Optional["_models.ResourceName"] @@ -37,7 +76,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2019_11_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.CheckResourceNameResult @@ -48,35 +88,28 @@ def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckResourceNameResult', pipeline_response) @@ -85,4 +118,6 @@ def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscriptions_operations.py index 44a1d6b996b44..99c27e88c4b61 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_subscriptions_operations.py @@ -5,24 +5,122 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_locations_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + 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 + ) + + +def build_get_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + 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 + ) + + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,6 +143,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id, # type: str @@ -60,7 +159,8 @@ def list_locations( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -68,34 +168,29 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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_locations_request( + subscription_id=subscription_id, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +208,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace def get( self, subscription_id, # type: str @@ -138,25 +235,15 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -170,8 +257,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -180,8 +270,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -189,30 +281,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -230,6 +319,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_tenants_operations.py index 8de73b1b9882d..36ec0a5762bb5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/_tenants_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/tenants') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TenantsOperations(object): """TenantsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py index 6d8f45c77a61b..abd8e21f33387 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SubscriptionClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py index 4cd4f335e0021..8f9a4e9cbff9d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-01-01" @@ -62,4 +62,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json index 5c7ce346bf289..6d6ccde6512f4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "SubscriptionClient", "filename": "_subscription_client", "description": "All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SubscriptionClientConfiguration\"], \"._operations_mixin\": [\"SubscriptionClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,29 +79,28 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "subscriptions": "SubscriptionsOperations", "tenants": "TenantsOperations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { "check_resource_name" : { "sync": { - "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def check_resource_name(\n self,\n resource_name_definition=None, # type: Optional[\"_models.ResourceName\"]\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckResourceNameResult\"\n", + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, "signature": "async def check_resource_name(\n self,\n resource_name_definition: Optional[\"_models.ResourceName\"] = None,\n **kwargs: Any\n) -\u003e \"_models.CheckResourceNameResult\":\n", - "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "doc": "\"\"\"Checks resource name validity.\n\nA resource name is valid if it is not a reserved word, does not contains a reserved word and\ndoes not start with a reserved word.\n\n:param resource_name_definition: Resource object with values for resource name and resource\n type.\n:type resource_name_definition:\n ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckResourceNameResult, or the result of cls(response)\n:rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "resource_name_definition" } diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py index 33d13aa520917..d85913ebd5535 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_subscription_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import SubscriptionClientConfiguration +from .operations import SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import SubscriptionClientConfiguration -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2021_01_01.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2021_01_01.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py index 25a76f1a6996b..e95939087d442 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._subscription_client import SubscriptionClient __all__ = ['SubscriptionClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py index 4bb922d539105..99cba9259f00b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(SubscriptionClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(SubscriptionClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2021-01-01" @@ -58,4 +58,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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py index dd8b88cd62ed2..f0553c1b15030 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/_subscription_client.py @@ -6,69 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import SubscriptionClientConfiguration +from .operations import SubscriptionClientOperationsMixin, SubscriptionsOperations, TenantsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SubscriptionClientConfiguration -from .operations import SubscriptionsOperations -from .operations import TenantsOperations -from .operations import SubscriptionClientOperationsMixin -from .. import models - - class SubscriptionClient(SubscriptionClientOperationsMixin): """All resource groups and resources exist within subscriptions. These operation enable you get information about your subscriptions and tenants. A tenant is a dedicated instance of Azure Active Directory (Azure AD) for your organization. :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.SubscriptionsOperations :ivar tenants: TenantsOperations operations - :vartype tenants: azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.TenantsOperations + :vartype tenants: + azure.mgmt.resource.subscriptions.v2021_01_01.aio.operations.TenantsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = SubscriptionClientConfiguration(credential, **kwargs) + self._config = SubscriptionClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenants = TenantsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenants = TenantsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py index 5d14abe7d8cf3..e1d3546a5d09e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscription_client_operations.py @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_client_operations import build_check_resource_name_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionClientOperationsMixin: + @distributed_trace_async async def check_resource_name( self, resource_name_definition: Optional["_models.ResourceName"] = None, @@ -32,7 +37,8 @@ async def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult @@ -43,29 +49,22 @@ async def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -79,4 +78,6 @@ async def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py index fc3419dabd4ab..439fa43d0b01b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_subscriptions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_get_request, build_list_locations_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id: str, @@ -58,7 +64,8 @@ def list_locations( :type include_extended_locations: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -66,36 +73,31 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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 include_extended_locations is not None: - query_parameters['includeExtendedLocations'] = self._serialize.query("include_extended_locations", include_extended_locations, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_locations_request( + subscription_id=subscription_id, + include_extended_locations=include_extended_locations, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + include_extended_locations=include_extended_locations, + 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('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace_async async def get( self, subscription_id: str, @@ -137,25 +141,15 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -169,8 +163,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -178,8 +175,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -187,30 +186,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -228,6 +224,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py index fdcd9f317284f..83fdba811a413 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/aio/operations/_tenants_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tenants_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py index 3d8d6c873a3ac..ca7bf68ff9401 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models.py @@ -12,13 +12,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus """ _attribute_map = { @@ -31,6 +32,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -62,6 +73,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -105,6 +118,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -131,8 +146,8 @@ class Location(msrest.serialization.Model): :vartype display_name: str :ivar regional_display_name: The display name of the location and its region. :vartype regional_display_name: str - :param metadata: Metadata of the location, such as lat/long, paired region, and others. - :type metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + :ivar metadata: Metadata of the location, such as lat/long, paired region, and others. + :vartype metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata """ _validation = { @@ -158,6 +173,10 @@ def __init__( self, **kwargs ): + """ + :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. + :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -171,8 +190,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] """ _attribute_map = { @@ -183,6 +202,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -206,8 +229,9 @@ class LocationMetadata(msrest.serialization.Model): :vartype latitude: str :ivar physical_location: The physical location of the Azure location. :vartype physical_location: str - :param paired_region: The regions paired to this region. - :type paired_region: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + :ivar paired_region: The regions paired to this region. + :vartype paired_region: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] :ivar home_location: The home location of an edge zone. :vartype home_location: str """ @@ -237,6 +261,11 @@ def __init__( self, **kwargs ): + """ + :keyword paired_region: The regions paired to this region. + :paramtype paired_region: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + """ super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -269,6 +298,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -276,10 +307,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay """ _attribute_map = { @@ -291,6 +322,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -299,14 +336,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -320,6 +357,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -330,10 +377,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -345,6 +392,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -380,6 +433,8 @@ def __init__( self, **kwargs ): + """ + """ super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None @@ -391,10 +446,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -411,6 +466,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = kwargs['name'] self.type = kwargs['type'] @@ -433,18 +494,18 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] - :param tags: A set of tags. The tags attached to the subscription. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags attached to the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -471,6 +532,20 @@ def __init__( self, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] + :keyword tags: A set of tags. The tags attached to the subscription. + :paramtype tags: dict[str, str] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -488,10 +563,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -507,6 +582,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] @@ -545,6 +626,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -612,6 +695,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -630,10 +715,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -649,6 +734,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs['next_link'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py index c49a2740875be..4e6ff453d5343 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_models_py3.py @@ -16,13 +16,14 @@ class CheckResourceNameResult(msrest.serialization.Model): """Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. - :param name: Name of Resource. - :type name: str - :param type: Type of Resource. - :type type: str - :param status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + :ivar name: Name of Resource. + :vartype name: str + :ivar type: Type of Resource. + :vartype type: str + :ivar status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", "Reserved". - :type status: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + :vartype status: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus """ _attribute_map = { @@ -39,6 +40,16 @@ def __init__( status: Optional[Union[str, "ResourceNameStatus"]] = None, **kwargs ): + """ + :keyword name: Name of Resource. + :paramtype name: str + :keyword type: Type of Resource. + :paramtype type: str + :keyword status: Is the resource name Allowed or Reserved. Possible values include: "Allowed", + "Reserved". + :paramtype status: str or + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceNameStatus + """ super(CheckResourceNameResult, self).__init__(**kwargs) self.name = name self.type = type @@ -70,6 +81,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -113,6 +126,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -139,8 +154,8 @@ class Location(msrest.serialization.Model): :vartype display_name: str :ivar regional_display_name: The display name of the location and its region. :vartype regional_display_name: str - :param metadata: Metadata of the location, such as lat/long, paired region, and others. - :type metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + :ivar metadata: Metadata of the location, such as lat/long, paired region, and others. + :vartype metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata """ _validation = { @@ -168,6 +183,10 @@ def __init__( metadata: Optional["LocationMetadata"] = None, **kwargs ): + """ + :keyword metadata: Metadata of the location, such as lat/long, paired region, and others. + :paramtype metadata: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationMetadata + """ super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -181,8 +200,8 @@ def __init__( class LocationListResult(msrest.serialization.Model): """Location list operation response. - :param value: An array of locations. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + :ivar value: An array of locations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] """ _attribute_map = { @@ -195,6 +214,10 @@ def __init__( value: Optional[List["Location"]] = None, **kwargs ): + """ + :keyword value: An array of locations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Location] + """ super(LocationListResult, self).__init__(**kwargs) self.value = value @@ -218,8 +241,9 @@ class LocationMetadata(msrest.serialization.Model): :vartype latitude: str :ivar physical_location: The physical location of the Azure location. :vartype physical_location: str - :param paired_region: The regions paired to this region. - :type paired_region: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + :ivar paired_region: The regions paired to this region. + :vartype paired_region: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] :ivar home_location: The home location of an edge zone. :vartype home_location: str """ @@ -251,6 +275,11 @@ def __init__( paired_region: Optional[List["PairedRegion"]] = None, **kwargs ): + """ + :keyword paired_region: The regions paired to this region. + :paramtype paired_region: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.PairedRegion] + """ super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -283,6 +312,8 @@ def __init__( self, **kwargs ): + """ + """ super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None @@ -290,10 +321,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay """ _attribute_map = { @@ -308,6 +339,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -316,14 +353,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources. - :type provider: str - :param resource: Resource on which the operation is performed: Profile, endpoint, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Service provider: Microsoft.Resources. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -342,6 +379,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Resources. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -352,10 +399,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Microsoft.Resources operations. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of Microsoft.Resources operations. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -370,6 +417,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Microsoft.Resources operations. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -405,6 +458,8 @@ def __init__( self, **kwargs ): + """ + """ super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None @@ -416,10 +471,10 @@ class ResourceName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the resource. - :type name: str - :param type: Required. The type of the resource. - :type type: str + :ivar name: Required. Name of the resource. + :vartype name: str + :ivar type: Required. The type of the resource. + :vartype type: str """ _validation = { @@ -439,6 +494,12 @@ def __init__( type: str, **kwargs ): + """ + :keyword name: Required. Name of the resource. + :paramtype name: str + :keyword type: Required. The type of the resource. + :paramtype type: str + """ super(ResourceName, self).__init__(**kwargs) self.name = name self.type = type @@ -461,18 +522,18 @@ class Subscription(msrest.serialization.Model): :ivar state: The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. Possible values include: "Enabled", "Warned", "PastDue", "Disabled", "Deleted". :vartype state: str or ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionState - :param subscription_policies: The subscription policies. - :type subscription_policies: + :ivar subscription_policies: The subscription policies. + :vartype subscription_policies: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies - :param authorization_source: The authorization source of the request. Valid values are one or + :ivar authorization_source: The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. - :type authorization_source: str - :param managed_by_tenants: An array containing the tenants managing the subscription. - :type managed_by_tenants: + :vartype authorization_source: str + :ivar managed_by_tenants: An array containing the tenants managing the subscription. + :vartype managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] - :param tags: A set of tags. The tags attached to the subscription. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags attached to the subscription. + :vartype tags: dict[str, str] """ _validation = { @@ -504,6 +565,20 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword subscription_policies: The subscription policies. + :paramtype subscription_policies: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionPolicies + :keyword authorization_source: The authorization source of the request. Valid values are one or + more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + RoleBased'. + :paramtype authorization_source: str + :keyword managed_by_tenants: An array containing the tenants managing the subscription. + :paramtype managed_by_tenants: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.ManagedByTenant] + :keyword tags: A set of tags. The tags attached to the subscription. + :paramtype tags: dict[str, str] + """ super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -521,10 +596,10 @@ class SubscriptionListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of subscriptions. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] - :param next_link: Required. The URL to get the next set of results. - :type next_link: str + :ivar value: An array of subscriptions. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :ivar next_link: Required. The URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -543,6 +618,12 @@ def __init__( value: Optional[List["Subscription"]] = None, **kwargs ): + """ + :keyword value: An array of subscriptions. + :paramtype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.Subscription] + :keyword next_link: Required. The URL to get the next set of results. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -581,6 +662,8 @@ def __init__( self, **kwargs ): + """ + """ super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None @@ -648,6 +731,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -666,10 +751,10 @@ class TenantListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: An array of tenants. - :type value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] - :param next_link: Required. The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of tenants. + :vartype value: list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :ivar next_link: Required. The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -688,6 +773,13 @@ def __init__( value: Optional[List["TenantIdDescription"]] = None, **kwargs ): + """ + :keyword value: An array of tenants. + :paramtype value: + list[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantIdDescription] + :keyword next_link: Required. The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(TenantListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py index ef07d8424e154..121fb33aee80c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/models/_subscription_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 LocationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The location type. """ REGION = "Region" EDGE_ZONE = "EdgeZone" -class RegionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RegionCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The category of the region. """ @@ -41,21 +26,21 @@ class RegionCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EXTENDED = "Extended" OTHER = "Other" -class RegionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RegionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the region. """ PHYSICAL = "Physical" LOGICAL = "Logical" -class ResourceNameStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceNameStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Is the resource name Allowed or Reserved """ ALLOWED = "Allowed" RESERVED = "Reserved" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription spending limit. """ @@ -63,7 +48,7 @@ class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OFF = "Off" CURRENT_PERIOD_OFF = "CurrentPeriodOff" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. """ @@ -73,7 +58,7 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" DELETED = "Deleted" -class TenantCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TenantCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Category of the tenant. """ diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py index 2f4de44a2ab36..80ecfc44e4b16 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscription_client_operations.py @@ -5,25 +5,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_check_resource_name_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Resources/checkResourceName') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + +# fmt: on class SubscriptionClientOperationsMixin(object): + @distributed_trace def check_resource_name( self, resource_name_definition=None, # type: Optional["_models.ResourceName"] @@ -37,7 +76,8 @@ def check_resource_name( :param resource_name_definition: Resource object with values for resource name and resource type. - :type resource_name_definition: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName + :type resource_name_definition: + ~azure.mgmt.resource.subscriptions.v2021_01_01.models.ResourceName :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckResourceNameResult, or the result of cls(response) :rtype: ~azure.mgmt.resource.subscriptions.v2021_01_01.models.CheckResourceNameResult @@ -48,29 +88,22 @@ def check_resource_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_resource_name.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if resource_name_definition is not None: - body_content = self._serialize.body(resource_name_definition, 'ResourceName') + _json = self._serialize.body(resource_name_definition, 'ResourceName') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_check_resource_name_request( + content_type=content_type, + json=_json, + template_url=self.check_resource_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -84,4 +117,6 @@ def check_resource_name( return cls(pipeline_response, deserialized, {}) return deserialized + check_resource_name.metadata = {'url': '/providers/Microsoft.Resources/checkResourceName'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py index a5a0667243c23..22cf961f2b2b8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_subscriptions_operations.py @@ -5,24 +5,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_locations_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + include_extended_locations = kwargs.pop('include_extended_locations', None) # type: Optional[bool] + + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/locations') + 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') + if include_extended_locations is not None: + query_parameters['includeExtendedLocations'] = _SERIALIZER.query("include_extended_locations", include_extended_locations, 'bool') + + # 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, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}') + 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 + ) + + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,6 +147,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_locations( self, subscription_id, # type: str @@ -63,7 +166,8 @@ def list_locations( :type include_extended_locations: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.LocationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocationListResult"] @@ -71,36 +175,31 @@ def list_locations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-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_locations.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(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 include_extended_locations is not None: - query_parameters['includeExtendedLocations'] = self._serialize.query("include_extended_locations", include_extended_locations, 'bool') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_locations_request( + subscription_id=subscription_id, + include_extended_locations=include_extended_locations, + template_url=self.list_locations.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_locations_request( + subscription_id=subscription_id, + include_extended_locations=include_extended_locations, + 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('LocationListResult', pipeline_response) + deserialized = self._deserialize("LocationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,11 +217,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + @distributed_trace def get( self, subscription_id, # type: str @@ -143,25 +244,15 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -175,8 +266,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -185,8 +279,10 @@ def list( """Gets all subscriptions for a tenant. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] @@ -194,30 +290,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -235,6 +328,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py index 904300d562111..b365dce1a604a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2021_01_01/operations/_tenants_operations.py @@ -5,24 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/tenants') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TenantsOperations(object): """TenantsOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +89,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.subscriptions.v2021_01_01.models.TenantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantListResult"] @@ -62,30 +98,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantListResult', pipeline_response) + deserialized = self._deserialize("TenantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +136,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py index f1bdac58861ae..5e59494673b31 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py index 9d9fb265d39b9..9d7921f6bf8c4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/_template_specs_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -69,12 +68,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(TemplateSpecsClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py index 72ea7ba9d89b6..332b210851ed6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_configuration.py @@ -12,7 +12,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 @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py index 0524da1ea80d7..283fcbaa95797 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/aio/_template_specs_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -67,12 +67,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(TemplateSpecsClient, self).__init__( diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py index 7c99491ce2da3..4005d4a7201ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['TemplateSpecsClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py index d11321efefc23..cbeb53bccd9d8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json index cec236545dbfb..5233052584e00 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "TemplateSpecsClient", "filename": "_template_specs_client", "description": "The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "template_specs": "TemplateSpecsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py index f83d23bbcf684..ce514fa2866c3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_template_specs_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class TemplateSpecsClient(object): """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2019_06_01_preview.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2019_06_01_preview.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2019_06_01_preview.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2019_06_01_preview.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py index 6520699c87dfb..9c8e93c3f82aa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._template_specs_client import TemplateSpecsClient __all__ = ['TemplateSpecsClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py index 57db33da9006b..1fa7ce7cb1eb8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py index 97804c92eac72..50fa95ccbe076 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/_template_specs_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from .. import models - - -class TemplateSpecsClient(object): +class TemplateSpecsClient: """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2019_06_01_preview.aio.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_spec_versions_operations.py index 35201adcc5f1d..a434d85018c3d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_spec_versions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_spec_versions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -58,7 +64,8 @@ async def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion @@ -69,39 +76,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,8 +111,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -134,7 +134,8 @@ async def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion @@ -145,42 +146,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -189,8 +180,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -216,34 +210,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -252,8 +236,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -280,34 +267,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +292,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -328,8 +307,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -337,36 +318,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,12 +357,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_specs_operations.py index 611488455cc64..d3f6c11db2235 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/aio/operations/_template_specs_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_specs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -126,7 +125,8 @@ async def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec @@ -137,41 +137,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -180,8 +170,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -197,7 +190,8 @@ async def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec @@ -208,35 +202,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -245,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -270,33 +256,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -304,6 +280,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, @@ -313,10 +291,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -324,36 +305,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -366,17 +342,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -389,10 +367,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -400,37 +381,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +420,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models.py index e6ce0d16122c7..28903d1e162f8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -76,6 +78,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -120,6 +124,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -131,22 +137,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2019_06_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -162,6 +168,24 @@ def __init__( self, **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.resource.templatespecs.v2019_06_01_preview.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.resource.templatespecs.v2019_06_01_preview.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -187,15 +211,15 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -229,6 +253,17 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + """ super(TemplateSpec, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -245,11 +280,11 @@ class TemplateSpecArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param kind: Required. The kind of artifact.Constant filled by server. Possible values - include: "template". - :type kind: str or + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: + "template". + :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind """ @@ -271,6 +306,10 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + """ super(TemplateSpecArtifact, self).__init__(**kwargs) self.path = kwargs['path'] self.kind = None # type: Optional[str] @@ -279,9 +318,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse """ _attribute_map = { @@ -292,6 +331,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -301,8 +345,9 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -320,6 +365,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -330,14 +380,14 @@ class TemplateSpecTemplateArtifact(TemplateSpecArtifact): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param kind: Required. The kind of artifact.Constant filled by server. Possible values - include: "template". - :type kind: str or + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: + "template". + :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -356,6 +406,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(TemplateSpecTemplateArtifact, self).__init__(**kwargs) self.kind = 'template' # type: str self.template = kwargs['template'] @@ -375,8 +431,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -398,6 +454,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -418,18 +478,18 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param artifacts: An array of Template Spec artifacts. - :type artifacts: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar artifacts: An array of Template Spec artifacts. + :vartype artifacts: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifact] - :param description: Template Spec version description. - :type description: str - :param template: The Azure Resource Manager template content. - :type template: any + :ivar description: Template Spec version description. + :vartype description: str + :ivar template: The Azure Resource Manager template content. + :vartype template: any """ _validation = { @@ -457,6 +517,20 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword artifacts: An array of Template Spec artifacts. + :paramtype artifacts: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifact] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword template: The Azure Resource Manager template content. + :paramtype template: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -494,6 +568,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -505,8 +581,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -525,6 +601,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -544,8 +625,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -567,5 +648,9 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py index f0dac4565a97e..39ad37533c5b5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_models_py3.py @@ -49,6 +49,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -81,6 +83,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -125,6 +129,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -136,22 +142,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2019_06_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -174,6 +180,24 @@ def __init__( 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.resource.templatespecs.v2019_06_01_preview.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.resource.templatespecs.v2019_06_01_preview.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 @@ -199,15 +223,15 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -246,6 +270,17 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + """ super(TemplateSpec, self).__init__(**kwargs) self.location = location self.tags = tags @@ -262,11 +297,11 @@ class TemplateSpecArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param kind: Required. The kind of artifact.Constant filled by server. Possible values - include: "template". - :type kind: str or + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: + "template". + :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind """ @@ -290,6 +325,10 @@ def __init__( path: str, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + """ super(TemplateSpecArtifact, self).__init__(**kwargs) self.path = path self.kind = None # type: Optional[str] @@ -298,9 +337,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse """ _attribute_map = { @@ -313,6 +352,11 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = error @@ -322,8 +366,9 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -343,6 +388,11 @@ def __init__( value: Optional[List["TemplateSpec"]] = None, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -353,14 +403,14 @@ class TemplateSpecTemplateArtifact(TemplateSpecArtifact): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param kind: Required. The kind of artifact.Constant filled by server. Possible values - include: "template". - :type kind: str or + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar kind: Required. The kind of artifact.Constant filled by server. Possible values include: + "template". + :vartype kind: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifactKind - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -382,6 +432,12 @@ def __init__( template: Any, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(TemplateSpecTemplateArtifact, self).__init__(path=path, **kwargs) self.kind = 'template' # type: str self.template = template @@ -401,8 +457,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -426,6 +482,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = tags @@ -446,18 +506,18 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param artifacts: An array of Template Spec artifacts. - :type artifacts: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar artifacts: An array of Template Spec artifacts. + :vartype artifacts: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifact] - :param description: Template Spec version description. - :type description: str - :param template: The Azure Resource Manager template content. - :type template: any + :ivar description: Template Spec version description. + :vartype description: str + :ivar template: The Azure Resource Manager template content. + :vartype template: any """ _validation = { @@ -491,6 +551,20 @@ def __init__( template: Optional[Any] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword artifacts: An array of Template Spec artifacts. + :paramtype artifacts: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecArtifact] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword template: The Azure Resource Manager template content. + :paramtype template: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = location self.tags = tags @@ -528,6 +602,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -539,8 +615,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -561,6 +637,11 @@ def __init__( value: Optional[List["TemplateSpecVersion"]] = None, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -580,8 +661,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -605,5 +686,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py index 2b2baf2db79a7..1d5ac8d4ff08a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/models/_template_specs_client_enums.py @@ -6,27 +6,12 @@ # 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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,14 +20,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecArtifactKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TemplateSpecArtifactKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of artifact. """ #: The artifact represents an embedded Azure Resource Manager template. TEMPLATE = "template" -class TemplateSpecExpandKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_spec_versions_operations.py index c538e4d212838..ff36678cbc6d8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_spec_versions_operations.py @@ -5,24 +5,228 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TemplateSpecVersionsOperations(object): """TemplateSpecVersionsOperations operations. @@ -45,6 +249,7 @@ 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 @@ -63,7 +268,8 @@ def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion @@ -74,39 +280,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,8 +315,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -140,7 +339,8 @@ def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersion @@ -151,42 +351,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -195,8 +385,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -223,34 +416,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -259,8 +442,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -288,34 +474,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,6 +499,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -337,8 +515,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -346,36 +526,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -388,12 +565,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_specs_operations.py index 0b48dc9f37fdb..3d8ac53b329e8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2019_06_01_preview/operations/_template_specs_operations.py @@ -5,24 +5,262 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2019-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/') + 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\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class TemplateSpecsOperations(object): """TemplateSpecsOperations operations. @@ -45,6 +283,7 @@ 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 @@ -71,38 +310,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +344,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -132,7 +364,8 @@ def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec @@ -143,41 +376,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -186,8 +409,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -204,7 +430,8 @@ def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpec @@ -215,35 +442,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -252,8 +468,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -278,33 +497,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -312,6 +521,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] @@ -322,10 +533,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -333,36 +547,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -375,17 +584,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -399,10 +610,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2019_06_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -410,37 +624,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,12 +663,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py index 7c99491ce2da3..4005d4a7201ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['TemplateSpecsClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py index c6dd436112f24..4e9f7a181b193 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json index 0bfe327effa39..e9e47e721d243 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "TemplateSpecsClient", "filename": "_template_specs_client", "description": "The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "template_specs": "TemplateSpecsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py index 85e02c654387d..90a2348d1f9a6 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_template_specs_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class TemplateSpecsClient(object): """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2021_03_01_preview.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py index 6520699c87dfb..9c8e93c3f82aa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._template_specs_client import TemplateSpecsClient __all__ = ['TemplateSpecsClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py index 0df87dbe71f01..332ca89e18f4d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py index 8f20ef06b85ef..bf6c3672de247 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/_template_specs_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from .. import models - - -class TemplateSpecsClient(object): +class TemplateSpecsClient: """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2021_03_01_preview.aio.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py index 6a149a1b54988..f545a5b57f626 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_spec_versions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_spec_versions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -58,7 +64,8 @@ async def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion @@ -69,39 +76,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,8 +111,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -134,7 +134,8 @@ async def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion @@ -145,42 +146,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -189,8 +180,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -216,34 +210,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -252,8 +236,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -280,34 +267,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +292,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -328,8 +307,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -337,36 +318,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,12 +357,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py index 68bcaeb2b8a74..72b8d0d03ac12 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/aio/operations/_template_specs_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_specs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -126,7 +125,8 @@ async def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec @@ -137,41 +137,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -180,8 +170,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -197,7 +190,8 @@ async def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec @@ -208,35 +202,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -245,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -270,33 +256,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -304,6 +280,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, @@ -313,10 +291,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -324,36 +305,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -366,17 +342,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -389,10 +367,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -400,37 +381,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +420,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py index ff4a9c7b9826e..b6ad6d3ce6d9d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -76,6 +78,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -120,6 +124,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -133,10 +139,10 @@ class LinkedTemplateArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -153,6 +159,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(LinkedTemplateArtifact, self).__init__(**kwargs) self.path = kwargs['path'] self.template = kwargs['template'] @@ -161,22 +173,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2021_03_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -192,6 +204,24 @@ def __init__( self, **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.resource.templatespecs.v2021_03_01_preview.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.resource.templatespecs.v2021_03_01_preview.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -217,18 +247,18 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str - :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically - a collection of key-value pairs. - :type metadata: any + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str + :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :vartype metadata: any :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -263,6 +293,20 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is + typically a collection of key-value pairs. + :paramtype metadata: any + """ super(TemplateSpec, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -275,9 +319,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse """ _attribute_map = { @@ -288,6 +332,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -297,8 +346,9 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -316,6 +366,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -335,8 +390,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -358,6 +413,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -378,23 +437,23 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec version description. - :type description: str - :param linked_templates: An array of linked template artifacts. - :type linked_templates: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec version description. + :vartype description: str + :ivar linked_templates: An array of linked template artifacts. + :vartype linked_templates: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] - :param metadata: The version metadata. Metadata is an open-ended object and is typically a + :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :type metadata: any - :param main_template: The main Azure Resource Manager template content. - :type main_template: any - :param ui_form_definition: The Azure Resource Manager template UI definition content. - :type ui_form_definition: any + :vartype metadata: any + :ivar main_template: The main Azure Resource Manager template content. + :vartype main_template: any + :ivar ui_form_definition: The Azure Resource Manager template UI definition content. + :vartype ui_form_definition: any """ _validation = { @@ -424,6 +483,25 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword linked_templates: An array of linked template artifacts. + :paramtype linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] + :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :paramtype metadata: any + :keyword main_template: The main Azure Resource Manager template content. + :paramtype main_template: any + :keyword ui_form_definition: The Azure Resource Manager template UI definition content. + :paramtype ui_form_definition: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -463,6 +541,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -474,8 +554,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -494,6 +574,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -513,8 +598,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -536,5 +621,9 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py index 33d58637d4976..0ca7a984d7554 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_models_py3.py @@ -49,6 +49,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -81,6 +83,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -125,6 +129,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -138,10 +144,10 @@ class LinkedTemplateArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -161,6 +167,12 @@ def __init__( template: Any, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(LinkedTemplateArtifact, self).__init__(**kwargs) self.path = path self.template = template @@ -169,22 +181,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2021_03_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -207,6 +219,24 @@ def __init__( 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.resource.templatespecs.v2021_03_01_preview.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.resource.templatespecs.v2021_03_01_preview.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 @@ -232,18 +262,18 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str - :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically - a collection of key-value pairs. - :type metadata: any + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str + :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :vartype metadata: any :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -284,6 +314,20 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is + typically a collection of key-value pairs. + :paramtype metadata: any + """ super(TemplateSpec, self).__init__(**kwargs) self.location = location self.tags = tags @@ -296,9 +340,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse """ _attribute_map = { @@ -311,6 +355,11 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = error @@ -320,8 +369,9 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -341,6 +391,11 @@ def __init__( value: Optional[List["TemplateSpec"]] = None, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -360,8 +415,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -385,6 +440,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = tags @@ -405,23 +464,23 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec version description. - :type description: str - :param linked_templates: An array of linked template artifacts. - :type linked_templates: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec version description. + :vartype description: str + :ivar linked_templates: An array of linked template artifacts. + :vartype linked_templates: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] - :param metadata: The version metadata. Metadata is an open-ended object and is typically a + :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :type metadata: any - :param main_template: The main Azure Resource Manager template content. - :type main_template: any - :param ui_form_definition: The Azure Resource Manager template UI definition content. - :type ui_form_definition: any + :vartype metadata: any + :ivar main_template: The main Azure Resource Manager template content. + :vartype main_template: any + :ivar ui_form_definition: The Azure Resource Manager template UI definition content. + :vartype ui_form_definition: any """ _validation = { @@ -459,6 +518,25 @@ def __init__( ui_form_definition: Optional[Any] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword linked_templates: An array of linked template artifacts. + :paramtype linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.LinkedTemplateArtifact] + :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :paramtype metadata: any + :keyword main_template: The main Azure Resource Manager template content. + :paramtype main_template: any + :keyword ui_form_definition: The Azure Resource Manager template UI definition content. + :paramtype ui_form_definition: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = location self.tags = tags @@ -498,6 +576,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -509,8 +589,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -531,6 +611,11 @@ def __init__( value: Optional[List["TemplateSpecVersion"]] = None, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -550,8 +635,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -575,5 +660,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py index bb7f08d82324d..ef8823668c7ee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/models/_template_specs_client_enums.py @@ -6,27 +6,12 @@ # 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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecExpandKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py index 6c7342aef707d..407a9ee5c94a1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_spec_versions_operations.py @@ -5,24 +5,228 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TemplateSpecVersionsOperations(object): """TemplateSpecVersionsOperations operations. @@ -45,6 +249,7 @@ 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 @@ -63,7 +268,8 @@ def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion @@ -74,39 +280,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,8 +315,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -140,7 +339,8 @@ def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersion @@ -151,42 +351,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -195,8 +385,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -223,34 +416,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -259,8 +442,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -288,34 +474,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,6 +499,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -337,8 +515,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -346,36 +526,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -388,12 +565,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py index ab652c09da1fb..15600a4921394 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_03_01_preview/operations/_template_specs_operations.py @@ -5,24 +5,262 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/') + 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\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class TemplateSpecsOperations(object): """TemplateSpecsOperations operations. @@ -45,6 +283,7 @@ 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 @@ -71,38 +310,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +344,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -132,7 +364,8 @@ def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec @@ -143,41 +376,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -186,8 +409,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -204,7 +430,8 @@ def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpec @@ -215,35 +442,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -252,8 +468,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -278,33 +497,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -312,6 +521,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] @@ -322,10 +533,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -333,36 +547,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -375,17 +584,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -399,10 +610,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_03_01_preview.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -410,37 +624,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - 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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,12 +663,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py index 7c99491ce2da3..4005d4a7201ea 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['TemplateSpecsClient'] -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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py index 75ba3a1ef6eb7..b22009c7267cb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json index 9e601046838d2..97c10aa4d0117 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_metadata.json @@ -5,13 +5,13 @@ "name": "TemplateSpecsClient", "filename": "_template_specs_client", "description": "The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"TemplateSpecsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "template_specs": "TemplateSpecsOperations", diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py index 0438a59cb9568..f6a13107c4a33 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_template_specs_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class TemplateSpecsClient(object): """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_05_01.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2021_05_01.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_05_01.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2021_05_01.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py index 4d0654b74058c..e5754a47ce68f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py index 6520699c87dfb..9c8e93c3f82aa 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._template_specs_client import TemplateSpecsClient __all__ = ['TemplateSpecsClient'] + +# `._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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py index 3f096f2b7c122..06a389f46ff4c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(TemplateSpecsClientConfiguration, 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(TemplateSpecsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py index 36f5f3fb80854..6c7deca6cc8d1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/_template_specs_client.py @@ -6,74 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import TemplateSpecsClientConfiguration +from .operations import TemplateSpecVersionsOperations, TemplateSpecsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import TemplateSpecsClientConfiguration -from .operations import TemplateSpecsOperations -from .operations import TemplateSpecVersionsOperations -from .. import models - - -class TemplateSpecsClient(object): +class TemplateSpecsClient: """The APIs listed in this specification can be used to manage Template Spec resources through the Azure Resource Manager. :ivar template_specs: TemplateSpecsOperations operations - :vartype template_specs: azure.mgmt.resource.templatespecs.v2021_05_01.aio.operations.TemplateSpecsOperations + :vartype template_specs: + azure.mgmt.resource.templatespecs.v2021_05_01.aio.operations.TemplateSpecsOperations :ivar template_spec_versions: TemplateSpecVersionsOperations operations - :vartype template_spec_versions: azure.mgmt.resource.templatespecs.v2021_05_01.aio.operations.TemplateSpecVersionsOperations + :vartype template_spec_versions: + azure.mgmt.resource.templatespecs.v2021_05_01.aio.operations.TemplateSpecVersionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription Id which forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = TemplateSpecsClientConfiguration(credential, subscription_id, **kwargs) + self._config = TemplateSpecsClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.template_specs = TemplateSpecsOperations(self._client, self._config, self._serialize, self._deserialize) + self.template_spec_versions = TemplateSpecVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.template_specs = TemplateSpecsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.template_spec_versions = TemplateSpecVersionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_spec_versions_operations.py index 884b44622406c..dba1f583df2a1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_spec_versions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_spec_versions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -58,7 +64,8 @@ async def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion @@ -69,39 +76,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,8 +111,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -134,7 +134,8 @@ async def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion @@ -145,42 +146,32 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -189,8 +180,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -216,34 +210,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -252,8 +236,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -280,34 +267,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +292,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -328,8 +307,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -337,36 +318,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,12 +357,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_specs_operations.py index 06f0a6e0e33bd..3b32fb1da6181 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/aio/operations/_template_specs_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._template_specs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -126,7 +125,8 @@ async def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec @@ -137,41 +137,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -180,8 +170,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -197,7 +190,8 @@ async def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec @@ -208,35 +202,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -245,8 +228,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -270,33 +256,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -304,6 +280,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand: Optional[Union[str, "_models.TemplateSpecExpandKind"]] = None, @@ -313,10 +291,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -324,36 +305,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -366,17 +342,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -389,10 +367,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -400,37 +381,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +420,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models.py index fd4cf9c9c4342..4935cd8c495f3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -76,6 +78,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -119,6 +123,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -132,10 +138,10 @@ class LinkedTemplateArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -152,6 +158,12 @@ def __init__( self, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(LinkedTemplateArtifact, self).__init__(**kwargs) self.path = kwargs['path'] self.template = kwargs['template'] @@ -160,22 +172,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2021_05_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -191,6 +203,24 @@ def __init__( self, **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.resource.templatespecs.v2021_05_01.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.resource.templatespecs.v2021_05_01.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -216,18 +246,18 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str - :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically - a collection of key-value pairs. - :type metadata: any + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str + :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :vartype metadata: any :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -262,6 +292,20 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is + typically a collection of key-value pairs. + :paramtype metadata: any + """ super(TemplateSpec, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -274,9 +318,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse """ _attribute_map = { @@ -287,6 +331,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -296,8 +345,8 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -315,6 +364,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -334,8 +387,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -357,6 +410,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -377,23 +434,23 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec version description. - :type description: str - :param linked_templates: An array of linked template artifacts. - :type linked_templates: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec version description. + :vartype description: str + :ivar linked_templates: An array of linked template artifacts. + :vartype linked_templates: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] - :param metadata: The version metadata. Metadata is an open-ended object and is typically a + :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :type metadata: any - :param main_template: The main Azure Resource Manager template content. - :type main_template: any - :param ui_form_definition: The Azure Resource Manager template UI definition content. - :type ui_form_definition: any + :vartype metadata: any + :ivar main_template: The main Azure Resource Manager template content. + :vartype main_template: any + :ivar ui_form_definition: The Azure Resource Manager template UI definition content. + :vartype ui_form_definition: any """ _validation = { @@ -423,6 +480,25 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword linked_templates: An array of linked template artifacts. + :paramtype linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] + :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :paramtype metadata: any + :keyword main_template: The main Azure Resource Manager template content. + :paramtype main_template: any + :keyword ui_form_definition: The Azure Resource Manager template UI definition content. + :paramtype ui_form_definition: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -462,6 +538,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -473,8 +551,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -492,6 +570,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = None @@ -511,8 +594,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -534,5 +617,9 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py index 571ab35add4cf..e016fc30ebaa1 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_models_py3.py @@ -49,6 +49,8 @@ def __init__( self, **kwargs ): + """ + """ super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -81,6 +83,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -124,6 +128,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -137,10 +143,10 @@ class LinkedTemplateArtifact(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param path: Required. A filesystem safe relative path of the artifact. - :type path: str - :param template: Required. The Azure Resource Manager template. - :type template: any + :ivar path: Required. A filesystem safe relative path of the artifact. + :vartype path: str + :ivar template: Required. The Azure Resource Manager template. + :vartype template: any """ _validation = { @@ -160,6 +166,12 @@ def __init__( template: Any, **kwargs ): + """ + :keyword path: Required. A filesystem safe relative path of the artifact. + :paramtype path: str + :keyword template: Required. The Azure Resource Manager template. + :paramtype template: any + """ super(LinkedTemplateArtifact, self).__init__(**kwargs) self.path = path self.template = template @@ -168,22 +180,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :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.resource.templatespecs.v2021_05_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -206,6 +218,24 @@ def __init__( 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.resource.templatespecs.v2021_05_01.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.resource.templatespecs.v2021_05_01.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 @@ -231,18 +261,18 @@ class TemplateSpec(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param location: Required. The location of the Template Spec. It cannot be changed after + :ivar location: Required. The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported Azure locations. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec description. - :type description: str - :param display_name: Template Spec display name. - :type display_name: str - :param metadata: The Template Spec metadata. Metadata is an open-ended object and is typically - a collection of key-value pairs. - :type metadata: any + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec description. + :vartype description: str + :ivar display_name: Template Spec display name. + :vartype display_name: str + :ivar metadata: The Template Spec metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :vartype metadata: any :ivar versions: High-level information about the versions within this Template Spec. The keys are the version names. Only populated if the $expand query parameter is set to 'versions'. :vartype versions: dict[str, @@ -283,6 +313,20 @@ def __init__( metadata: Optional[Any] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec. It cannot be changed after + Template Spec creation. It must be one of the supported Azure locations. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec description. + :paramtype description: str + :keyword display_name: Template Spec display name. + :paramtype display_name: str + :keyword metadata: The Template Spec metadata. Metadata is an open-ended object and is + typically a collection of key-value pairs. + :paramtype metadata: any + """ super(TemplateSpec, self).__init__(**kwargs) self.location = location self.tags = tags @@ -295,9 +339,9 @@ def __init__( class TemplateSpecsError(msrest.serialization.Model): """Template Specs error response. - :param error: Common error response for all Azure Resource Manager APIs to return error details + :ivar error: Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :type error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse """ _attribute_map = { @@ -310,6 +354,11 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: Common error response for all Azure Resource Manager APIs to return error + details for failed operations. (This also follows the OData error response format.). + :paramtype error: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.ErrorResponse + """ super(TemplateSpecsError, self).__init__(**kwargs) self.error = error @@ -319,8 +368,8 @@ class TemplateSpecsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Specs. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + :ivar value: An array of Template Specs. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -340,6 +389,10 @@ def __init__( value: Optional[List["TemplateSpec"]] = None, **kwargs ): + """ + :keyword value: An array of Template Specs. + :paramtype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec] + """ super(TemplateSpecsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -359,8 +412,8 @@ class TemplateSpecUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -384,6 +437,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecUpdateModel, self).__init__(**kwargs) self.tags = tags @@ -404,23 +461,23 @@ class TemplateSpecVersion(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param location: Required. The location of the Template Spec Version. It must match the - location of the parent Template Spec. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: Template Spec version description. - :type description: str - :param linked_templates: An array of linked template artifacts. - :type linked_templates: + :ivar location: Required. The location of the Template Spec Version. It must match the location + of the parent Template Spec. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: Template Spec version description. + :vartype description: str + :ivar linked_templates: An array of linked template artifacts. + :vartype linked_templates: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] - :param metadata: The version metadata. Metadata is an open-ended object and is typically a + :ivar metadata: The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. - :type metadata: any - :param main_template: The main Azure Resource Manager template content. - :type main_template: any - :param ui_form_definition: The Azure Resource Manager template UI definition content. - :type ui_form_definition: any + :vartype metadata: any + :ivar main_template: The main Azure Resource Manager template content. + :vartype main_template: any + :ivar ui_form_definition: The Azure Resource Manager template UI definition content. + :vartype ui_form_definition: any """ _validation = { @@ -458,6 +515,25 @@ def __init__( ui_form_definition: Optional[Any] = None, **kwargs ): + """ + :keyword location: Required. The location of the Template Spec Version. It must match the + location of the parent Template Spec. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: Template Spec version description. + :paramtype description: str + :keyword linked_templates: An array of linked template artifacts. + :paramtype linked_templates: + list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.LinkedTemplateArtifact] + :keyword metadata: The version metadata. Metadata is an open-ended object and is typically a + collection of key-value pairs. + :paramtype metadata: any + :keyword main_template: The main Azure Resource Manager template content. + :paramtype main_template: any + :keyword ui_form_definition: The Azure Resource Manager template UI definition content. + :paramtype ui_form_definition: any + """ super(TemplateSpecVersion, self).__init__(**kwargs) self.location = location self.tags = tags @@ -497,6 +573,8 @@ def __init__( self, **kwargs ): + """ + """ super(TemplateSpecVersionInfo, self).__init__(**kwargs) self.description = None self.time_created = None @@ -508,8 +586,8 @@ class TemplateSpecVersionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: An array of Template Spec versions. - :type value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + :ivar value: An array of Template Spec versions. + :vartype value: list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -529,6 +607,11 @@ def __init__( value: Optional[List["TemplateSpecVersion"]] = None, **kwargs ): + """ + :keyword value: An array of Template Spec versions. + :paramtype value: + list[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion] + """ super(TemplateSpecVersionsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -548,8 +631,8 @@ class TemplateSpecVersionUpdateModel(AzureResourceBase): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.SystemData - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -573,5 +656,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TemplateSpecVersionUpdateModel, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py index bb7f08d82324d..ef8823668c7ee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/models/_template_specs_client_enums.py @@ -6,27 +6,12 @@ # 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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class TemplateSpecExpandKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TemplateSpecExpandKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Includes version information with the Template Spec. VERSIONS = "versions" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_spec_versions_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_spec_versions_operations.py index b125f284a2f23..9521372997e89 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_spec_versions_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_spec_versions_operations.py @@ -5,24 +5,228 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + template_spec_version, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "templateSpecVersion": _SERIALIZER.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) + +# fmt: on class TemplateSpecVersionsOperations(object): """TemplateSpecVersionsOperations operations. @@ -45,6 +249,7 @@ 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 @@ -63,7 +268,8 @@ def create_or_update( :param template_spec_version: The version of the Template Spec. :type template_spec_version: str :param template_spec_version_model: Template Spec Version supplied to the operation. - :type template_spec_version_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion + :type template_spec_version_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion @@ -74,39 +280,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec_version_model, 'TemplateSpecVersion') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,8 +315,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -140,7 +339,8 @@ def update( :type template_spec_version: str :param template_spec_version_update_model: Template Spec Version resource with the tags to be updated. - :type template_spec_version_update_model: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel + :type template_spec_version_update_model: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpecVersion, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersion @@ -151,42 +351,32 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if template_spec_version_update_model is not None: - body_content = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') + _json = self._serialize.body(template_spec_version_update_model, 'TemplateSpecVersionUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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(request, stream=False, **kwargs) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -195,8 +385,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -223,34 +416,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) response = pipeline_response.http_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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpecVersion', pipeline_response) @@ -259,8 +442,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -288,34 +474,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecVersion': self._serialize.url("template_spec_version", template_spec_version, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_spec_version=template_spec_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) 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.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,6 +499,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}'} # type: ignore + + @distributed_trace def list( self, resource_group_name, # type: str @@ -337,8 +515,10 @@ def list( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] + :return: An iterator like instance of either TemplateSpecVersionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecVersionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecVersionsListResult"] @@ -346,36 +526,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + 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, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TemplateSpecVersionsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecVersionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -388,12 +565,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_specs_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_specs_operations.py index 063d0719e60f1..1c9b33d2dac86 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_specs_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/templatespecs/v2021_05_01/operations/_template_specs_operations.py @@ -5,24 +5,262 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + template_spec_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}') + 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\._\(\)]+$'), + "templateSpecName": _SERIALIZER.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] + + api_version = "2021-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/') + 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\._\(\)]+$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + +# fmt: on class TemplateSpecsOperations(object): """TemplateSpecsOperations operations. @@ -45,6 +283,7 @@ 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 @@ -71,38 +310,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(template_spec, 'TemplateSpec') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(template_spec, 'TemplateSpec') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +344,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -132,7 +364,8 @@ def update( :param template_spec_name: Name of the Template Spec. :type template_spec_name: str :param template_spec: Template Spec resource with the tags to be updated. - :type template_spec: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel + :type template_spec: + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecUpdateModel :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec @@ -143,41 +376,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if template_spec is not None: - body_content = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') + _json = self._serialize.body(template_spec, 'TemplateSpecUpdateModel') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -186,8 +409,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -204,7 +430,8 @@ def get( :type template_spec_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response :return: TemplateSpec, or the result of cls(response) :rtype: ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpec @@ -215,35 +442,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TemplateSpec', pipeline_response) @@ -252,8 +468,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -278,33 +497,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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\._\(\)]+$'), - 'templateSpecName': self._serialize.url("template_spec_name", template_spec_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_spec_name=template_spec_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -312,6 +521,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, expand=None, # type: Optional[Union[str, "_models.TemplateSpecExpandKind"]] @@ -322,10 +533,13 @@ def list_by_subscription( :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -333,36 +547,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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_subscription.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] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + template_url=self.list_by_subscription.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_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -375,17 +584,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -399,10 +610,13 @@ def list_by_resource_group( :type resource_group_name: str :param expand: Allows for expansion of additional Template Spec details in the response. Optional. - :type expand: str or ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind + :type expand: str or + ~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecExpandKind :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TemplateSpecsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] + :return: An iterator like instance of either TemplateSpecsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resource.templatespecs.v2021_05_01.models.TemplateSpecsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TemplateSpecsListResult"] @@ -410,37 +624,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-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 = { - '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\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, '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_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + expand=expand, + 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('TemplateSpecsListResult', pipeline_response) + deserialized = self._deserialize("TemplateSpecsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -453,12 +663,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.TemplateSpecsError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )